开发者

how to create a repositionable image

开发者 https://www.devze.com 2023-02-22 09:38 出处:网络
i would to create an image that the user can drag and drop any where in the page. then the positi开发者_Go百科on would be saved so when he opens the page again it will be where he left it.

i would to create an image that the user can drag and drop any where in the page.

then the positi开发者_Go百科on would be saved so when he opens the page again it will be where he left it.

thanks


Essentially you want to record the mouse position, then absolutely position the element based on where the mouse is, and on mouse up serialise the coordinates and save them. You could either send them to the server via ajax, or (depending on context), save them into the users local storage. That would have the benefit of avoiding a server round trip if the use case is fairly trivial.

http://docs.jquery.com/UI/Draggable is a nice example of how this would work without having to do the difficult parts!

0

精彩评论

暂无评论...
验证码 换一张
取 消