From 9721ed3cc9ae67f0b11324ab684b8e1bcbc34faf Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Sun, 24 Aug 2025 10:10:49 -0600 Subject: [PATCH] Double tap to add events to avoid false clicks and interence with touch scroll. --- src/components/CalendarView.vue | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/CalendarView.vue b/src/components/CalendarView.vue index b88f728..27b41b8 100644 --- a/src/components/CalendarView.vue +++ b/src/components/CalendarView.vue @@ -47,6 +47,11 @@ const selection = ref({ startDate: null, dayCount: 0 }) const isDragging = ref(false) const dragAnchor = ref(null) +// Double-tap state +const lastTapTime = ref(0) +const lastTapDate = ref(null) +const DOUBLE_TAP_DELAY = 300 // milliseconds + const WEEK_MS = 7 * 24 * 60 * 60 * 1000 const minVirtualWeek = computed(() => { @@ -305,6 +310,16 @@ function clearSelection() { selection.value = { startDate: null, dayCount: 0 } } +function isDoubleTap(dateStr) { + const now = Date.now() + const isDouble = lastTapDate.value === dateStr && now - lastTapTime.value <= DOUBLE_TAP_DELAY + + lastTapTime.value = now + lastTapDate.value = dateStr + + return isDouble +} + function startDrag(dateStr) { if (calendarStore.config.select_days === 0) return isDragging.value = true @@ -383,7 +398,10 @@ onBeforeUnmount(() => { }) const handleDayMouseDown = (dateStr) => { - startDrag(dateStr) + // Check for double tap - only start drag on second tap + if (isDoubleTap(dateStr)) { + startDrag(dateStr) + } } const handleDayMouseEnter = (dateStr) => { @@ -404,7 +422,10 @@ const handleDayMouseUp = (dateStr) => { } const handleDayTouchStart = (dateStr) => { - startDrag(dateStr) + // Check for double tap - only start drag on second tap + if (isDoubleTap(dateStr)) { + startDrag(dateStr) + } } const handleDayTouchMove = (dateStr) => {