From d562a20cdda84cc8d2950d1ffbb59893604606a3 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Sat, 28 Jan 2023 08:42:42 +1100 Subject: Flash search results --- src/components/TimeLine.vue | 35 ++++++++++++++++++++++++++++++++--- src/index.css | 8 ++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/components/TimeLine.vue b/src/components/TimeLine.vue index e767074..0cdd106 100644 --- a/src/components/TimeLine.vue +++ b/src/components/TimeLine.vue @@ -56,8 +56,15 @@
-
+
+ + +
+
+
{{idToEvent.get(id)!.title}} @@ -1320,6 +1327,8 @@ watch(endDate, onStateChg); const searchEvent = ref(null as null | HistEvent); // Holds most recent search result let pendingSearch = false; // Used to prevent removal of search highlighting until after a search jump has completed +const flashedEventId = ref(-1); // Holds ID of event to flash after a jump + // -1 indicates no flash, 0 indicates pending search, >0 indicates an event ID watch(() => props.searchTarget, () => { const event = props.searchTarget[0]; @@ -1362,6 +1371,10 @@ watch(() => props.searchTarget, () => { scaleIdx.value = SCALES.findIndex((s: number) => s == tempScale); } pendingSearch = true; + flashedEventId.value = 0; + } else { // Flash result + flashedEventId.value = event.id; + setTimeout(() => {flashedEventId.value = -1;}, 300); } searchEvent.value = event; @@ -1374,6 +1387,14 @@ watch(idToEvent, () => { } }); +// For flashing search result after a jump +watch(idToEvent, () => { + if (flashedEventId.value == 0 && searchEvent.value != null && idToEvent.value.has(searchEvent.value.id)){ + flashedEventId.value = searchEvent.value.id; + setTimeout(() => {flashedEventId.value = -1;}, 300); + } +}); + // ========== For bound resets ========== watch(() => props.reset, () => { @@ -1537,10 +1558,18 @@ function eventStyles(eventId: number){ }; } +function getCtgColor(ctg: string){ + if (ctg == 'discovery'){ + return store.color.accent; + } else { + return store.color.altDark; + } +} + function eventImgStyles(eventId: number){ const event = idToEvent.value.get(eventId)!; let isSearchResult = searchEvent.value != null && searchEvent.value.id == eventId; - let color = event.ctg == 'discovery' ? store.color.accent : store.color.altDark; + let color = getCtgColor(event.ctg); return { width: store.eventImgSz + 'px', height: store.eventImgSz + 'px', diff --git a/src/index.css b/src/index.css index 92325b4..58e424c 100644 --- a/src/index.css +++ b/src/index.css @@ -25,6 +25,14 @@ opacity: 1; } } +.fadeout-leave-to { + opacity: 0; +} +.fadeout-leave-active { + transition-property: opacity; + transition-duration: 300ms; + transition-timing-function: ease-out; +} .animate-red-then-fade { animation-name: red-then-fade; animation-duration: 500ms; -- cgit v1.2.3