tladamso-uNZObgmCpkU@public.gmane.org
2006-Sep-14 17:47 UTC
Restricting where a draggable can be dropped
Is there any way to restrict where a draggable can go? I have a section on a web page that I would like to allow a draggable to only be moved within it. Do I need to look at Sortables, or is this even possible? I know I can restrict to either vertical or horizontal movement, but I would like to allow both - but only within a given area. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
you can use a function in the snap option: new Draggable(''my_draggable'',{snap: function(x,y){ x = x<100 ? 100 : (x>500 ? 500 : x); y = y<100 ? 100 : (y>500 ? 500 : y); return [x,y]; }); This example snap function would limit the draggable within 100,100 and 500,500. You can also call Position.within(element,x,y) inside the snap function to test if the draggable is within the container. --Ken Snyder -----Original Message----- From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of tladamso-uNZObgmCpkU@public.gmane.org Sent: Thursday, September 14, 2006 11:48 AM To: Ruby on Rails: Spinoffs Subject: [Rails-spinoffs] Restricting where a draggable can be dropped Is there any way to restrict where a draggable can go? I have a section on a web page that I would like to allow a draggable to only be moved within it. Do I need to look at Sortables, or is this even possible? I know I can restrict to either vertical or horizontal movement, but I would like to allow both - but only within a given area. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Take a look at function test dragdrop6_test.html. I think it does what you''re asking for. TAG On Sep 14, 2006, at 11:47 AM, tladamso-uNZObgmCpkU@public.gmane.org wrote:> > Is there any way to restrict where a draggable can go? I have a > section on a web page that I would like to allow a draggable to > only be > moved within it. > > Do I need to look at Sortables, or is this even possible? I know I > can > restrict to either vertical or horizontal movement, but I would > like to > allow both - but only within a given area. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This is exactly what I needed. Thanks both Tom and Ken for the quick responses :-) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, that''s ok if you need to limit only where draggable can go but i want to be able that draggable element jumps for 20px and can be dragged inside the parentNode is this possible too_? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, that''s ok if you need to limit only where draggable can go but i want to be able that draggable element jumps for 20px and can be dragged inside the parentNode is this possible too_? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2006-Oct-11 19:25 UTC
Re: Restricting where a draggable can be dropped
arseniq a écrit :> Hi, > > that''s ok if you need to limit only where draggable can go but i want > to be able that draggable element jumps for 20px and can be dragged > inside the parentNode > > is this possible too_?I believe there''s an example for "jumping" (I assume you mean movement has a 20px resolution) on the wiki. As for position constraints, you can also handle this with the same callback function, but you''ll need the Position object''s methods to determine the parent container''s coordinates and bound your movements within those. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---