From 22635b1202bde599b9d1a58bdf2bcfa733bdac8d Mon Sep 17 00:00:00 2001 From: newcat Date: Sat, 23 Mar 2024 00:57:27 +0100 Subject: [PATCH] Timeline: minor visual improvements --- src/timeline/components/Timeline.vue | 13 +++++++------ src/timeline/styles/Timeline.scss | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/timeline/components/Timeline.vue b/src/timeline/components/Timeline.vue index 783a575..8c1b55b 100644 --- a/src/timeline/components/Timeline.vue +++ b/src/timeline/components/Timeline.vue @@ -13,6 +13,7 @@
+
@@ -104,7 +105,7 @@ const markers = computed(() => { lastItemEnd.value + globalState.snapUnits ); - for (let unit = 0; unit < maxUnit; unit += markerSpacing.value.space) { + for (let unit = markerSpacing.value.space; unit < maxUnit; unit += markerSpacing.value.space) { const x = unitToPixel(unit); const nthMarker = Math.floor(unit / markerSpacing.value.space); if (nthMarker % markerSpacing.value.majorMultiplier === 0) { @@ -122,7 +123,7 @@ function unselectAllItems() { }); } -function updateLastNoteEnd() { +function updateLastItemEnd() { const newLastItemEnd = timeline.items.reduce((p, i) => Math.max(p, i.end), 0); if (dragItem.value && newLastItemEnd < lastItemEnd.value) { // do nothing because shrinking the content while dragging results in strange behaviour @@ -130,8 +131,8 @@ function updateLastNoteEnd() { } lastItemEnd.value = newLastItemEnd; } -watch(dragItem, updateLastNoteEnd); -watch(() => timeline.items.map((i) => i.end), updateLastNoteEnd); +watch(dragItem, updateLastItemEnd); +watch(() => timeline.items.map((i) => i.end), updateLastItemEnd); function mousedown(ev: MouseEvent) { const target = ev.target as HTMLElement | null; @@ -295,9 +296,9 @@ function drop(track: Track, ev: DragEvent) { function onHeaderClick(ev: MouseEvent): void { let x = ev.offsetX; - if ((ev.target as HTMLElement).classList.contains("__header-row")) { + if ((ev.target as HTMLElement).classList.contains("__spacer")) { // clicked on the padding area on top of the track headers - x = 0; + x = el.value!.scrollLeft; } const tick = pixelToUnit(x); diff --git a/src/timeline/styles/Timeline.scss b/src/timeline/styles/Timeline.scss index 336da41..f2a8135 100644 --- a/src/timeline/styles/Timeline.scss +++ b/src/timeline/styles/Timeline.scss @@ -19,7 +19,8 @@ .__content { position: relative; - background-image: linear-gradient(90deg, var(--surface-border) 1px, transparent 1px), linear-gradient(90deg, var(--surface-overlay) 1px, transparent 1px); + background-image: linear-gradient(90deg, var(--surface-border) 1px, transparent 1px), + linear-gradient(90deg, var(--surface-overlay) 1px, transparent 1px); background-position: ($headerWidth - 1px) -1px; background-repeat: repeat; min-width: 100%; @@ -31,15 +32,27 @@ .__header-row { height: 40px; - padding-left: $headerWidth; background-color: var(--surface-card); position: sticky; top: 0; z-index: 4; + & > .__spacer { + width: $headerWidth; + height: 100%; + position: sticky; + background-color: var(--surface-card); + left: 0; + z-index: 5; + } + & > .__container { - position: relative; + position: absolute; + top: 0; + left: $headerWidth; height: 100%; + width: calc(100% - #{$headerWidth}); + z-index: 4; } }