Skip to content

Commit

Permalink
Customize drag from outside event's length
Browse files Browse the repository at this point in the history
  • Loading branch information
ducfilan committed Nov 21, 2024
1 parent 9f082fb commit 9442c72
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)

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

Check failure on line 152 in src/addons/dragAndDrop/EventContainerWrapper.js

View workflow job for this annotation

GitHub Actions / Test

'end' is constant
}
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 9442c72

Please sign in to comment.