From cd19b9fc49965732a4dd1def35fd695587101165 Mon Sep 17 00:00:00 2001 From: Raphael Bernhart Date: Fri, 21 Jan 2022 17:13:38 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20Improve=20hearbeat=20animation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/HeartbeatBar.vue | 47 +++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/components/HeartbeatBar.vue b/src/components/HeartbeatBar.vue index be0b122ed..7143e7168 100644 --- a/src/components/HeartbeatBar.vue +++ b/src/components/HeartbeatBar.vue @@ -1,6 +1,6 @@ @@ -168,9 +172,30 @@ export default { getBeatTitle(beat) { return `${this.$root.datetime(beat.time)}` + ((beat.msg) ? ` - ${beat.msg}` : ``); + }, + // Toggling the activeSibling class on hover over the current hover item + toggleActivateSibling(e) { + // Variable definition + const element = e.target; + const previous = element.previousSibling; + const next = element.nextSibling; + + // Return if the hovered element has empty class + if (element.classList.contains("empty")) { + return; + } + + // Check if Previous Sibling is heartbar element and doesn't have the empty class + if (previous.children && !previous.classList.contains("empty")) { + previous.classList.toggle("active-sibling"); + } + // Check if Next Sibling is heartbar element and doesn't have the empty class + if (next.children && next.classList.contains("empty")) { + next.classList.toggle("active-sibling"); + } } }, -} +};