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 isDragging = ref(false)
const dragAnchor = ref(null) 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 WEEK_MS = 7 * 24 * 60 * 60 * 1000
const minVirtualWeek = computed(() => { const minVirtualWeek = computed(() => {
@ -305,6 +310,16 @@ function clearSelection() {
selection.value = { startDate: null, dayCount: 0 } 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) { function startDrag(dateStr) {
if (calendarStore.config.select_days === 0) return if (calendarStore.config.select_days === 0) return
isDragging.value = true isDragging.value = true
@ -383,7 +398,10 @@ onBeforeUnmount(() => {
}) })
const handleDayMouseDown = (dateStr) => { const handleDayMouseDown = (dateStr) => {
// Check for double tap - only start drag on second tap
if (isDoubleTap(dateStr)) {
startDrag(dateStr) startDrag(dateStr)
}
} }
const handleDayMouseEnter = (dateStr) => { const handleDayMouseEnter = (dateStr) => {
@ -404,7 +422,10 @@ const handleDayMouseUp = (dateStr) => {
} }
const handleDayTouchStart = (dateStr) => { const handleDayTouchStart = (dateStr) => {
// Check for double tap - only start drag on second tap
if (isDoubleTap(dateStr)) {
startDrag(dateStr) startDrag(dateStr)
}
} }
const handleDayTouchMove = (dateStr) => { const handleDayTouchMove = (dateStr) => {