Skip to content

Commit

Permalink
fix: Customize drag from outside event's length (#2681)
Browse files Browse the repository at this point in the history
  • Loading branch information
ducfilan authored Nov 25, 2024
1 parent 11818b5 commit 2ed9465
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/addons/dragAndDrop/EventContainerWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ class EventContainerWrapper extends React.Component {
boundaryBox
)

const end = this._calculateDnDEnd(start)

this.context.draggable.onDropFromOutside({
start,
end: slotMetrics.nextSlot(start),
end,
allDay: false,
resource,
})
Expand All @@ -133,11 +135,25 @@ class EventContainerWrapper extends React.Component {
{ y: point.y, x: point.x },
bounds
)
const end = slotMetrics.nextSlot(start)
const end = this._calculateDnDEnd(start)
const event = this.context.draggable.dragFromOutsideItem()
this.update(event, slotMetrics.getRange(start, end, false, true))
}

_calculateDnDEnd = (start) => {
const { accessors, slotMetrics, localizer } = this.props
const event = this.context.draggable.dragFromOutsideItem()
const { duration: eventDuration } = eventTimes(event, accessors, localizer)

let end = slotMetrics.nextSlot(start)
const eventHasDuration = !isNaN(eventDuration)
if (eventHasDuration) {
const eventEndSlot = localizer.add(start, eventDuration, 'milliseconds')
end = new Date(Math.max(eventEndSlot, end))
}
return end
}

updateParentScroll = (parent, node) => {
setTimeout(() => {
const draggedEl = qsa(node, '.rbc-addons-dnd-drag-preview')[0]
Expand All @@ -152,8 +168,8 @@ class EventContainerWrapper extends React.Component {
parent,
Math.min(
draggedEl.offsetTop -
parent.offsetHeight +
draggedEl.offsetHeight,
parent.offsetHeight +
draggedEl.offsetHeight,
parent.scrollHeight
)
)
Expand Down

0 comments on commit 2ed9465

Please sign in to comment.