Skip to content

Commit

Permalink
enable mousemove on hour view (fix #58) and trigger change on click (fix
Browse files Browse the repository at this point in the history
 #57)

(cherry picked from commit 978ebf1)
  • Loading branch information
mskocik committed Jul 15, 2023
1 parent 2ed4a5d commit 4cadbcd
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/lib/components/Time.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
date = innerDate;
date.setHours(0,0,0,0);
}
let canSelect = true;
const dispatch = createEventDispatcher();
$: {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}
}
/**
Expand Down

0 comments on commit 4cadbcd

Please sign in to comment.