Alfred-Skyblue / vue-draggable-plus

Universal Drag-and-Drop Component Supporting both Vue 3 and Vue 2
https://vue-draggable-plus.pages.dev/en/
MIT License
2.71k stars 106 forks source link

Suggestion: Log Dragging Direction #121

Closed Ben-Avrahami closed 2 months ago

Ben-Avrahami commented 2 months ago

hey, a small suggestion i have the would benefit me in using this package. i would like to be able to see the dragged total direction (left/right) in the onEnd event. maybe there is a way to do it now that im unaware of? thanks

Alfred-Skyblue commented 2 months ago

newIndex - oldIndex > 0 ? 'right' : 'left'

Ben-Avrahami commented 2 months ago

newIndex - oldIndex > 0 ? 'right' : 'left'

i mean physically, my app is a tinder like app, and i have only 1 elements, I'm not dragging inside an array or something. i just want to know if the item was dragged left or right on the screen to emit the correct event. also for the same use case, maybe we can allow not bind the dragging to an array, since for some use cases like mine, the dragging shouldn't manipulate the data, only allow dragging for the HTML elements, onEnd i respond to the dragging event appropriately, but for my use case it shouldn't be bonded to an array.

Alfred-Skyblue commented 2 months ago

Can I understand that you need to know the direction of mouse movement when the mouse is clicked and dragged?

Ben-Avrahami commented 2 months ago

Can I understand that you need to know the direction of mouse movement when the mouse is clicked and dragged?

exactly, when mouse drag is ended and when touchDragging is ended.

Alfred-Skyblue commented 2 months ago

Record the mouse position or element position in onStart, and calculate with the new position obtained in onEnd.