Mouse/touch event handling improvement

- prefer passive handlers
- fix event moving on touch
- faster selection updates
This commit is contained in:
Leo Vasanko
2025-08-27 08:04:29 -06:00
parent ecae48fd85
commit 5a0d6804bc
6 changed files with 19 additions and 23 deletions

View File

@@ -18,7 +18,6 @@ function restoreCalendarState(store, snap) {
store.weekend = Array.isArray(snap.weekend) ? [...snap.weekend] : snap.weekend
store.config = JSON.parse(JSON.stringify(snap.config))
store.events = new Map([...snap.events].map(([k, v]) => [k, { ...v }]))
store.eventsMutation = (store.eventsMutation + 1) % 1_000_000_000
}
export function calendarHistory({ store }) {
@@ -36,8 +35,7 @@ export function calendarHistory({ store }) {
function serializeForComparison() {
const evCount = store.events instanceof Map ? store.events.size : 0
const em = store.eventsMutation || 0
return `${em}|${evCount}|${store.today}|${JSON.stringify(store.config)}`
return `${evCount}|${store.today}|${JSON.stringify(store.config)}`
}
function pushSnapshot() {

View File

@@ -124,7 +124,6 @@ function createMomentumDrag({
return
}
applyDragPosition(e.touches[0].clientY, reasonDragTouch)
e.preventDefault()
}
function handlePointerDown(e) {
if (e.button !== undefined && e.button !== 0) return
@@ -158,7 +157,7 @@ function createMomentumDrag({
window.addEventListener('touchmove', onTouchMove, { passive: false })
window.addEventListener('touchend', endDrag, { passive: false })
window.addEventListener('touchcancel', endDrag, { passive: false })
e.preventDefault()
if (e.cancelable) e.preventDefault()
}
function onPointerLockChange() {
const lockedEl = document.pointerLockElement