|
[ANN] Snap to grid for Draggables: msg#00079lang.ruby.rails.spinoffs
Heya, Following an idea from Saimon (http://dev.rubyonrails.org/ticket/ 2826) and Borlum (http://dev.rubyonrails.org/ticket/2583) and possibly others, script.aculo.us Draggables now sport a new "snap" option that works like this: snap:25 snap to a 25x25 grid (0,0 is at the elements 0,0 coordinate) snap:[10,25] same as above but with different x/y grid size snap:function(x,y) { return [x,y] } do-it-yourself grid implementation The latter can also be used for stuff like constraints, for example: snap: function(x,y) { return[ x<100 ? (x > 0 ? x : 0 ) : 100, y<50 ? (y > 0 ? y : 0) : 50]; } will constraint the dragging of the element to a 100 by 50 box (not calculating in the element's width or height). With some more tinkering you can implement some pretty advanced stuff, like basing the snapping/constraint on the current position of other elements. Hope you find that useful! Comments are welcome! Cheers Thomas |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: InPlaceEditor question: 00079, Ricky Wirapratigta |
|---|---|
| Next by Date: | Project idea: 00079, William Parry |
| Previous by Thread: | InPlaceEditor questioni: 00079, Brandon Dove |
| Next by Thread: | Re: [ANN] Snap to grid for Draggables: 00079, Duane Johnson |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |