Event On isDragging Ended #138
-
I asked "Is there any event which lets me know when the user has stopped dragging the selected elements eg something like isDraggingEnd ?" And you responded "Yes for sure, if you check the docs for callbacks, there is callback which is triggered on every end of interaction. So in your case you’d look for true on the isDragging callback object key." but I don't follow :-( I've created a dragend event and added it to your _defineProperty for _reset
to get what I need. That is, when on mouse up, following a dragging selection attempt, a single event is thrown. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi Andrew, lovely to hear from you! No need for a custom event. 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 🍻 |
Beta Was this translation helpful? Give feedback.
-
I didn't think that would work till I tried it. Thank you (I've now removed the code I added.) |
Beta Was this translation helpful? Give feedback.
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:
It will only console.log after the user stopped dragging. You can see this in practice in this codepen.
Cheers 🍻