Mark Chaimungkalanont
2005-Sep-16 03:25 UTC
[Rails-spinoffs] Drag and Drop effects without dragging and dropping?
Hi there, This is very much a newbie question. I''ve been playing with the wiki.script.aculo.us libraries drag & drop functionality (sortable list) for a few days and trying to figure out how the scripts work, without a lot of luck. I was wondering how the "move" of the option is achieved (the "flying" option effect, if you will) and whether I can achieve the same effects myself. Simply, I want a function that will simulate me dragging an option across to the other list, so I can then implement a "Move All" button that will move all the items from one list to the other. I''m guessing it would be some combination of the Effect.MoveBy effect but I''m not really sure where I''d start. If anyone can point me to any documentation (on prototype or effects) that would help me out, I''d be most appreciative. Cheers, Mark C -- ------------------------------------- ATLASSIAN - http://www.atlassian.com/ Confluence - the enterprise wiki - tried it yet? http://www.atlassian.com/confluence/
Martin Bialasinski
2005-Sep-16 09:46 UTC
[Rails-spinoffs] Drag and Drop effects without dragging and dropping?
On 16/09/05, Mark Chaimungkalanont <mark@atlassian.com> wrote:> I was wondering how the "move" of the option is achieved (the "flying" option effect, if > you will)You mean the effect that snaps the element into its place when you let go of the element? This is done by the MoveBy effect. Search for "revert" in the code.> and whether I can achieve the same effects myself. Simply, I want a function > that will simulate me dragging an option across to the other list, so I can then implement > a "Move All" button that will move all the items from one list to the other.Tricky. MoveTo needs proper coordinates. You have to transform the current coordinates of the element to coordinates with its 0-point at the position it would have if it would already be in the target list. Maybe something in the direction of cloning the element to the target list with visibility hidden, retrieving the positions of both elements wrt the document(0,0) point, calculate the difference. Remove the clone, move the source element to the target list, set its top/left to the calculated offset. MoveTo (0,0). Bye, Martin