anseki / plain-draggable

The simple and high performance library to allow HTML/SVG element to be dragged.
https://anseki.github.io/plain-draggable/
MIT License
773 stars 99 forks source link

Retract back to starting point #64

Closed cliffcourt closed 3 years ago

cliffcourt commented 3 years ago

Thanks for this great draggable project. It looks very straight forward to use.

This isn't an issue with the project, but I didn;t know how else to ask the question!

The one requirement I have is that if the the dragged item does not get close enough to another point so it can snap to it, when the drag is ended (i.e. mouse up), the dragged item should slowly move back to the its starting position. I can see how I can snap it back to the start position, but that isn't ideal. So is there a way to allow for the dragged item to "wind back" to the start position? I'll be drawing a straight line from the start position to the item as it's being dragged, so ideally it should wind back along this line to the start. If it snaps to a different point the line, it obviously would simply stay there with the line in place.

Many thanks

anseki commented 3 years ago

Hi @cliffcourt, thank you for the comment.

This example may help you: https://anseki.github.io/plain-draggable/#ex-060-stage Drag the draggable element, and release that on the outside of blue grid lines. Then, the draggable element should move back to the its starting position.

cliffcourt commented 3 years ago

Many thanks anseki! That behaviour is exactly what I'm looking for. Somehow I missed it while going through the various examples you provide.

All the best Cliff

anseki commented 3 years ago

:smile: