Hey I am implementing the drag and drop operations using Kineticjs
Now I want the images to snap to each other if they get close ..
I saw the animals on beach example in KineticJs which was no help to me for my functionality
then saw the jquery snap to grid thing..But if I use that then I’ll have to get rid of KineticJs .Is thr any way to implement jquery snap propery to the elements in kineticJs
cause in jquery they have passed the id of the img to make it draggable and then snap.
So how can I use this with my kinetic.js images
jquery draggable: http://jqueryui.com/demos/draggable/#snap-to
kinetic.js: http://www.kineticjs.com/
Thanks
Ashish
If you’re going for something that snaps to an nxm grid you’d want to add a listener that calls a function which snaps it. You’d probably want to do this at “dragend”
http://www.html5canvastutorials.com/kineticjs/html5-canvas-drag-and-drop-events-tutorial/
… 100×100 grid for square tiles
ex: if YourObject.x = 325, then you’ll have Math.floor(3.25)*100+50 = 350. The left and top should both be at 300, while, the center is at 350.
Edit, oops missed part of the question. For snapping to other squares, here’s what I’d do: