-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
A series of sortable containers is created, each with the following constructor options:
{
group: {
name: 'drag',
pull(to, from, element, e) {
console.log(e) // this is where we can see the difference in behaviour
}
}In the pull() callback above, we console.log(e) to show the event that was passed to the callback.
When dragging an element from one container to a different container which already has at least one element in it, the object being logged is of the following form:
DragEvent {isTrusted: true, dataTransfer: DataTransfer, screenX: 530, screenY: 297, clientX: 530, …}And when dragging an element from one container to a different container which is currently empty, the object being logged is of the following form:
{clientX: 496, clientY: 213, target: div.col-items-content, rootEl: div.col-items-content}The context of this issue is I want to tie a e.ctrlKey if-check to return a different value from the pull() callback, like the following:
pull(to, from, element, e) {
if (e.ctrlKey) {
return 'clone'
} else {
return true
}
}This works great when pulling an element onto an already-filled container, but unfortunately, because of the behaviour described above, this doesn't work when pulling an element into a container which is so far still empty.
JSFiddle of the reproduction: https://jsfiddle.net/xc6hLy17/4/
In this JSFiddle, play with the elements, try to empty a container and fill it again, and check that a DragEvent is correctly fired when dragging an item onto a non-empty ul container, but not when dragging an item onto an empty container.