Skip to content

Event On isDragging Ended #138

Locked Answered by ThibaultJanBeyer
AndrewPixel asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Andrew, lovely to hear from you!

No need for a custom event.
As mentioned, you can use the event called callback to know when the user stopped dragging the selected elements.

Here is the pseudocode:

const ds = new DragSelect({
  selectables: document.querySelectorAll('.item')
});

ds.subscribe('callback', ({ isDragging, items }) => {
  if(isDragging) {
    console.log("user has stopped dragging the selected elements:", items)
  }
})

It will only console.log after the user stopped dragging. You can see this in practice in this codepen.

Cheers 🍻

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ThibaultJanBeyer
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants