From 4cadbcd697c75b46b10289c73813c47d0f8f59c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sko=C4=8D=C3=ADk?= Date: Fri, 14 Jul 2023 12:34:38 +0200 Subject: [PATCH] enable mousemove on hour view (fix #58) and trigger change on click (fix #57) (cherry picked from commit 978ebf114ed63d9a662ff7f0740e284cbee9b743) --- src/lib/components/Time.svelte | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/lib/components/Time.svelte b/src/lib/components/Time.svelte index ea232bd..64de46e 100644 --- a/src/lib/components/Time.svelte +++ b/src/lib/components/Time.svelte @@ -56,7 +56,6 @@ date = innerDate; date.setHours(0,0,0,0); } - let canSelect = true; const dispatch = createEventDispatcher(); $: { @@ -216,8 +215,7 @@ * @param {any} e */ function onClick(e) { - if (!canSelect || !e.target) return; - if ((e.type === 'mousemove' && !handleMoveMove) || (!isMinuteView && e.target.tagName !== 'BUTTON')) return; + if (!e.target) return; let a = 0; let b = 0; if (e.target.tagName === 'BUTTON' && (!isMinuteView || minuteIncrement === 1)) { @@ -285,12 +283,13 @@ innerDate.setMinutes(degree); } innerDate = innerDate; - canSelect = false; - dispatch('time', innerDate); - if (!handleMoveMove && isMinuteView) setTimeout(() => { dispatch('close') }, 300); - if (enableViewToggle && !isMinuteView) isMinuteView = true; - enableViewToggle = true; - setTimeout(() => { enableViewToggle = false; canSelect = true }, 200); + + // handle only final click, not mouse move + if (!handleMoveMove) { + dispatch('time', innerDate); + isMinuteView && setTimeout(() => { dispatch('close') }, 300); + if (!isMinuteView && enableViewToggle) isMinuteView = true; + } } /**