Mouse/touch event handling improvement
- prefer passive handlers - fix event moving on touch - faster selection updates
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user