Event moving fixed again, splitting correctly for recurrent events.

This commit is contained in:
Leo Vasanko committed 2025-08-22 21:13:21 -06:00
1 parent 4529d0c412
commit d794758b54
2 files changed
+117 -3

No files matched your search

+25 -3
View File
@@ -161,6 +161,25 @@ function startLocalDrag(init, evt) {
window.addEventListener('pointercancel', onDragPointerUp, { passive: false })
}
// Determine date under pointer: traverse DOM to find day cell carrying data-date attribute
function getDateUnderPointer(x, y, el) {
let cur = el
while (cur) {
if (cur.dataset && cur.dataset.date) {
return { date: cur.dataset.date }
}
cur = cur.parentElement
}
// Fallback: elementFromPoint scan
const probe = document.elementFromPoint(x, y)
let p = probe
while (p) {
if (p.dataset && p.dataset.date) return { date: p.dataset.date }
p = p.parentElement
}
return null
}
function onDragPointerMove(e) {
const st = dragState.value
if (!st) return
@@ -234,9 +253,12 @@ function normalizeDateOrder(aStr, bStr) {
}
function applyRangeDuringDrag(st, startDate, endDate) {
// If dragging a virtual occurrence, map to base move without changing recurrence pattern mid-series.
// We disallow resizing individual virtual occurrences; treat as move of whole series anchor.
if (st.isVirtual && st.mode !== 'move') return
if (st.isVirtual) {
if (st.mode !== 'move') return // no resize for virtual occurrence
// Split-move: occurrence being dragged treated as first of new series
store.splitMoveVirtualOccurrence(st.id, st.startDate, startDate, endDate)
return
}
store.setEventRange(st.id, startDate, endDate, { mode: st.mode })
}