dasboe
2007-Jun-07 16:40 UTC
Sortables should act differenty when a list item is dragged out of the list
I started using prototype and script.sculo.us 2-3 weeks ago and I love just about every thing about it :) Sortables are also great but a part of its behavior seems (at least to me) not like what a user in most cases would expect. Lets take the sortable list example at http://wiki.script.aculo.us/scriptaculous/page/print/SortableListsDemo. When a user drags a list item to the other list everything is great: The feedback given to the user that he is actually inserting a list item in the other list by creating space in the list is very smooth :) What I don''t like is what happens when the user reconsiders his decision to drag the item. He has to move the item back to it''s original position (where was that again?). I think it would be much more intuitiv if things would revert to the beginning state when a list item is draged out of a list. This is what I also think the user is used to from most desktop applications. So I had a closer look at the code of dragdrop.js to see if this could be easily changed: - I noticed that there is an onHover callback function for droppables but no onUnHover or whatever it might be called. The API says the onHover is mainly used by Sortable but I think it''s just nice to have - just as an onUnHover would be great. This was already adressed at http://dev.rubyonrails.org/ticket/5631 but the code suggested there is not correct. So I implement this as: changes in the Droppables.show : old -> if(this.last_active) this.deactivate(this.last_active); new -> if(this.last_active) this.deactivate(this.last_active, element, this.last_active.element); changes in Droppables.deactivate : old -> if(drop.hoverclass) old -> Element.removeClassName(drop.element, drop.hoverclass); old -> this.last_active = null; new -> if(drop.hoverclass) new -> Element.removeClassName(drop.element, drop.hoverclass); new -> if (this.last_active.onUnHover) new -> this.last_active.onUnHover(drag, dropElement); new -> this.last_active = null; an example on how this can be used you can find at http://tests.marketcrash.net/test2.html. I really think this is nice to have and it just adds 2 lines of code! I thought with this in place it would be a good starting point to change the rest of my intended list behaviour (reverting the list state once onUnHover is called on a list item). But before I go ahead and run into big trouble I thought it would be good to post all this here. thanks for reading this far and for any comments and suggestions... ''boe --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---