![]() |
How correctly store position of draggable items - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How correctly store position of draggable items (/showthread.php?tid=51745) |
How correctly store position of draggable items - El Forum - 05-16-2012 [eluser]darian311[/eluser] I'm trying to store the position of some image elements after allowing the user to drag them around on top of my game frame. However everytime I retrieve the offsetLeft and the offsetTop values, they end up moving further left and to the right, instead of showing up at the exact locations as before. What's the best way to get and store the new positions of htmlelements after a user has dragged them around inside a div? My source is included. If there's a best practice for this, I haven't found it yet. If it helps here's the rendered source too: Code: function handleDrop(event, ui){ How correctly store position of draggable items - El Forum - 05-16-2012 [eluser]CroNiX[/eluser] Would be better to use a "sortable" from jQuery ui over a draggable. That's what it's purpose is and has methods to give you the order of the items in the sortable. http://jqueryui.com/demos/sortable/ How correctly store position of draggable items - El Forum - 05-16-2012 [eluser]weboap[/eluser] add to @CroNiX answer http://www.cs.rit.edu/~rjb6296/jquery_demo/ from http://old.nabble.com/saving-portlet-state-td21951006s27240.html hope it help. |