Jeremy Kitchen
2006-Jun-14 22:44 UTC
generic onDragStart onDrag and onDragFinish events extracted from scriptaculous?
Hi folks. I''m working on a project where I need some drag and drop, but I need to implement what happens in a very different way, so I''m creating my own class for it. I don''t want to reinvent the wheel and redo Thomas'' excellent drag/drop functionality, nor do I want to copy/paste his code over into mine. So, I was wondering, has anyone tried to extract the very low level basic drag and drop functionality out of scriptaculous? If not, I''ll try to do this myself (in such a way that scriptaculous might be able to be ported over to it, and other libraries take advantage of the functionality). It seems like it will be a fair bit of work (especially if I want to maintain backward compatibility with scriptaculous), so if someone has already started this, or has done this, it would be nice to save some time :) Thanks! -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org http://www.pirate-party.us/ -- defend your rights _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Tom Gregory
2006-Jun-14 23:04 UTC
Re: generic onDragStart onDrag and onDragFinish events extracted from scriptaculous?
It''s the theme of the day: create an observable class, and attach it to the Draggable. See SortableObserver in the Scriptaculous source for an example. TAG On Jun 14, 2006, at 4:44 PM, Jeremy Kitchen wrote:> Hi folks. > > I''m working on a project where I need some drag and drop, but I > need to > implement what happens in a very different way, so I''m creating my > own class > for it. I don''t want to reinvent the wheel and redo Thomas'' excellent > drag/drop functionality, nor do I want to copy/paste his code over > into mine. > > So, I was wondering, has anyone tried to extract the very low level > basic drag > and drop functionality out of scriptaculous? If not, I''ll try to > do this > myself (in such a way that scriptaculous might be able to be ported > over to > it, and other libraries take advantage of the functionality). It > seems like > it will be a fair bit of work (especially if I want to maintain > backward > compatibility with scriptaculous), so if someone has already > started this, or > has done this, it would be nice to save some time :) > > Thanks! > > -Jeremy > > -- > Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org > > http://www.pirate-party.us/ -- defend your rights > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Jeremy Kitchen
2006-Jun-14 23:30 UTC
Re: generic onDragStart onDrag and onDragFinish events extracted from scriptaculous?
On Wednesday 14 June 2006 16:04, Tom Gregory wrote:> It''s the theme of the day: create an observable class, and attach it > to the Draggable. > > See SortableObserver in the Scriptaculous source for an example.I don''t see how SortableObserver is in any way related to my question? Maybe I''m blind, or maybe you meant to type something else ;) Thanks! -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org http://www.pirate-party.us/ -- defend your rights _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Tom Gregory
2006-Jun-14 23:44 UTC
Re: generic onDragStart onDrag and onDragFinish events extracted from scriptaculous?
I''ve been in a rut today, so perhaps I misinterpreted what you''re looking for: As I understood your question, you wanted to be able to use the drag/ drop functionality that comes with scriptaculous, but define your own default behaviors for onDragStart, onDrag, on DragFinish, and onUpdate. If this is what you want, then an observer is the way to go. The Sortables class adds functionality to the basic drag/drop in this way. If you mean something else, then I answered the wrong question. TAG On Jun 14, 2006, at 5:30 PM, Jeremy Kitchen wrote:> On Wednesday 14 June 2006 16:04, Tom Gregory wrote: >> It''s the theme of the day: create an observable class, and attach it >> to the Draggable. >> >> See SortableObserver in the Scriptaculous source for an example. > > I don''t see how SortableObserver is in any way related to my question? > > Maybe I''m blind, or maybe you meant to type something else ;) > > Thanks! > > -Jeremy > > -- > Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org > > http://www.pirate-party.us/ -- defend your rights > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Jeremy Kitchen
2006-Jun-14 23:52 UTC
Re: generic onDragStart onDrag and onDragFinish events extracted from scriptaculous?
On Wednesday 14 June 2006 16:44, Tom Gregory wrote:> I''ve been in a rut today, so perhaps I misinterpreted what you''re > looking for: > > As I understood your question, you wanted to be able to use the drag/ > drop functionality that comes with scriptaculous, but define your own > default behaviors for onDragStart, onDrag, on DragFinish, and > onUpdate. If this is what you want, then an observer is the way to > go. The Sortables class adds functionality to the basic drag/drop in > this way.no, because I need to handle the positioning of the object I''m dragging myself. And SortableObserver appears to be an observer for Sortables, where I''m working with Draggables :) -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org http://www.pirate-party.us/ -- defend your rights _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Ryan Gahl
2006-Jun-15 14:02 UTC
Re: generic onDragStart onDrag and onDragFinish events extracted from scriptaculous?
I think he mentioned SortableObserver just as an example. There is also the more generic DraggableObserver construct available... this.draggable = new Draggable($("someElement"), dragOptions); this.draggableObserver = { onStart: function(eventName, draggable, event) { if (draggable == this.draggable) { doSomething(); } }.bind(this), onDrag: function(eventName, draggable, event) { if (draggable == this.moveable) { doSomething(); } }.bind(this), onEnd: function(eventName, draggable, event) { if (draggable == this.moveable) { doSomething(); } }.bind(this) } Draggables.addObserver(this.draggableObserver); The onDrag event seems to be the important one for you, and it does fire after scriptaculous updates the position, so you can then change the position yourself in that function to what you want. This may produce odd results but could point you in the right direction. But, you could always just override the updateDrag or the draw method for your Draggable instances (for the next bit I''m assuming you already have a Draggable called myDraggable)... myDraggable.updateDrag = function(event, pointer) { //insert custom code, copying what you need from dragdrop.js }; myDraggable.draw = function(point) { //insert custom code, copying what you need from dragdrop.js }; On 6/14/06, Jeremy Kitchen <kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org> wrote:> > On Wednesday 14 June 2006 16:44, Tom Gregory wrote: > > I''ve been in a rut today, so perhaps I misinterpreted what you''re > > looking for: > > > > As I understood your question, you wanted to be able to use the drag/ > > drop functionality that comes with scriptaculous, but define your own > > default behaviors for onDragStart, onDrag, on DragFinish, and > > onUpdate. If this is what you want, then an observer is the way to > > go. The Sortables class adds functionality to the basic drag/drop in > > this way. > > no, because I need to handle the positioning of the object I''m dragging > myself. And SortableObserver appears to be an observer for Sortables, > where > I''m working with Draggables :) > > -Jeremy > > -- > Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org > > http://www.pirate-party.us/ -- defend your rights > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs