Double tap to add events to avoid false clicks and interence with touch scroll.

This commit is contained in:
Leo Vasanko 2025-08-24 10:10:49 -06:00
parent 15f7ff4fec
commit 9721ed3cc9

View File

@ -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,8 +398,11 @@ onBeforeUnmount(() => {
})
const handleDayMouseDown = (dateStr) => {
// Check for double tap - only start drag on second tap
if (isDoubleTap(dateStr)) {
startDrag(dateStr)
}
}
const handleDayMouseEnter = (dateStr) => {
if (isDragging.value) {
@ -404,8 +422,11 @@ const handleDayMouseUp = (dateStr) => {
}
const handleDayTouchStart = (dateStr) => {
// Check for double tap - only start drag on second tap
if (isDoubleTap(dateStr)) {
startDrag(dateStr)
}
}
const handleDayTouchMove = (dateStr) => {
if (isDragging.value) {