taye / interact.js

JavaScript drag and drop, resizing and multi-touch gestures with inertia and snapping for modern browsers (and also IE9+)
http://interactjs.io/
MIT License
12.19k stars 782 forks source link

How to implement elements snapping to each other functionality? #1017

Open razmatinyan opened 7 months ago

razmatinyan commented 7 months ago

Hello. Does anyone know how to implement the elements snapping to each other functionality in 1.10.20 version? Didn't find any solution.

Daniel199438 commented 6 months ago

@razmatinyan Look at this fiddle: https://jsfiddle.net/a0knv69j/9/

You just need to add in dynamicTargets the other elements x and y coordinates you want to snap to. I refresh it on every dragstart to the actual position of my other elements.