Major new version #2
@ -101,6 +101,24 @@ function handleEventPointerDown(span, event) {
|
||||
const hasVirtualMarker = typeof idStr === 'string' && idStr.includes('_v_')
|
||||
const baseId = hasVirtualMarker ? idStr.slice(0, idStr.lastIndexOf('_v_')) : idStr
|
||||
const isVirtual = hasVirtualMarker
|
||||
// Determine which day within the span was grabbed so we maintain relative position
|
||||
let anchorDate = span.startDate
|
||||
try {
|
||||
const spanDays = daysInclusive(span.startDate, span.endDate)
|
||||
const targetEl = event.currentTarget
|
||||
if (targetEl && spanDays > 0) {
|
||||
const rect = targetEl.getBoundingClientRect()
|
||||
const relX = event.clientX - rect.left
|
||||
const dayWidth = rect.width / spanDays
|
||||
let dayIndex = Math.floor(relX / dayWidth)
|
||||
if (!isFinite(dayIndex)) dayIndex = 0
|
||||
if (dayIndex < 0) dayIndex = 0
|
||||
if (dayIndex >= spanDays) dayIndex = spanDays - 1
|
||||
anchorDate = addDaysStr(span.startDate, dayIndex)
|
||||
}
|
||||
} catch (e) {
|
||||
// Fallback to startDate if any calculation fails
|
||||
}
|
||||
startLocalDrag(
|
||||
{
|
||||
id: baseId,
|
||||
@ -109,7 +127,7 @@ function handleEventPointerDown(span, event) {
|
||||
mode: 'move',
|
||||
pointerStartX: event.clientX,
|
||||
pointerStartY: event.clientY,
|
||||
anchorDate: span.startDate,
|
||||
anchorDate,
|
||||
startDate: span.startDate,
|
||||
endDate: span.endDate,
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user