Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DragEvent not passed to pull() if target is empty #1471

Closed
JivanRoquet opened this issue Mar 14, 2019 · 1 comment
Closed

DragEvent not passed to pull() if target is empty #1471

JivanRoquet opened this issue Mar 14, 2019 · 1 comment

Comments

@JivanRoquet
Copy link

JivanRoquet commented Mar 14, 2019

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.

@JivanRoquet JivanRoquet changed the title Different event is passed to pull() depending on target being empty or not DragEvent not passed to pull() if target container is empty Mar 14, 2019
@JivanRoquet JivanRoquet changed the title DragEvent not passed to pull() if target container is empty DragEvent not passed to pull() if target is empty Mar 14, 2019
@owen-m1
Copy link
Member

owen-m1 commented Mar 17, 2019

Solved in b483211.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants