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: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---

Reply via email to