From bb4f7f6dd4054de2c29113f72bc43777337aed9b Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Mon, 10 Oct 2022 19:24:56 +1100 Subject: Add timeline bound indicators to baseline --- src/App.vue | 22 ++++++++++++++++++---- src/components/BaseLine.vue | 39 +++++++++++++++++++++++++++++++++++---- src/components/TimeLine.vue | 44 +++++++++++++++----------------------------- src/index.css | 23 +++++++++++++++++++++++ src/lib.ts | 6 ++++++ 5 files changed, 97 insertions(+), 37 deletions(-) create mode 100644 src/lib.ts diff --git a/src/App.vue b/src/App.vue index 2555d3f..95009e7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -18,8 +18,10 @@
- + :vert="vert" :initialStart="data.start" :initialEnd="data.end" + class="grow basis-full min-h-0 outline outline-1" + @close="onTimelineClose(idx)" @bound-chg="onBoundChg($event, idx)"/> +
@@ -50,14 +52,21 @@ onMounted(updateAreaDims) // For multiple timelines const vert = computed(() => contentHeight.value > contentWidth.value); -const timelineData = ref([{}]); +const timelineData = ref([]); +let nextTimelineId = 1; +function genTimelineData(){ + let data = {id: nextTimelineId, start: -500, end: 500}; + nextTimelineId++; + return data; +} +timelineData.value.push(genTimelineData()); function onTimelineAdd(){ if (vert.value && contentWidth.value / (timelineData.value.length + 1) < 150 || !vert.value && contentHeight.value / (timelineData.value.length + 1) < 150){ console.log('Reached timeline min size'); return; } - timelineData.value.push({}); + timelineData.value.push(genTimelineData()); } function onTimelineClose(idx: number){ if (timelineData.value.length == 1){ @@ -66,6 +75,11 @@ function onTimelineClose(idx: number){ } timelineData.value.splice(idx, 1); } +function onBoundChg(newBounds: [number, number], idx: number){ + let data = timelineData.value[idx]; + data.start = newBounds[0]; + data.end = newBounds[1]; +} // For resize handling let lastResizeHdlrTime = 0; // Used to throttle resize handling diff --git a/src/components/BaseLine.vue b/src/components/BaseLine.vue index f0008f9..bde2e56 100644 --- a/src/components/BaseLine.vue +++ b/src/components/BaseLine.vue @@ -1,21 +1,28 @@ diff --git a/src/components/TimeLine.vue b/src/components/TimeLine.vue index 796f5c7..2cdf31f 100644 --- a/src/components/TimeLine.vue +++ b/src/components/TimeLine.vue @@ -32,7 +32,8 @@ - - diff --git a/src/index.css b/src/index.css index 44996b5..e050c82 100644 --- a/src/index.css +++ b/src/index.css @@ -3,6 +3,29 @@ @tailwind components; @tailwind utilities; +/* For transitions/animations */ +.fade-enter-from, .fade-leave-to { + opacity: 0; +} +.fade-enter-active, .fade-leave-active { + transition-property: opacity; + transition-duration: 300ms; + transition-timing-function: ease-out; +} +.animate-fadein { + animation-name: fadein; + animation-duration: 300ms; + animation-timing-function: ease-in; +} +@keyframes fadein { + from { + opacity: 0; + } + to { + opacity: 1; + } +} + /* Other */ @font-face { font-family: Ubuntu; diff --git a/src/lib.ts b/src/lib.ts new file mode 100644 index 0000000..e482f72 --- /dev/null +++ b/src/lib.ts @@ -0,0 +1,6 @@ +/* + * Project-wide globals + */ + +export const MIN_DATE = -1000; +export const MAX_DATE = 1000; -- cgit v1.2.3