Control draggable movement in jQuery -
how can control de movement of draggable in jquery?
i need similar "snap grid" draggable moves every "x" , "y" pixels
i can't use "grid: [x, y]" (2d) because need make drag on isometric grid (3d) (i develop grid later, first need controll drag)
for example: when start dragging, draggable shouldn't move, has snap position when "x" , "y" under conditions
thanks in advance!
try using options inherent in .draggable() function @ http://jqueryui.com/demos/draggable/
basically says need have snap option set true this:
$( ".selector" ).draggable({ snap: true, snapmode:'outer', snaptolerance:40 }); snapmode "...determines edges of snap elements draggable snap to. ignored if snap false. possible values: 'inner', 'outer', 'both'." , snaptolerance "...the distance in pixels snap element edges @ snapping should occur."
or try using grid option. created want: "...grid snaps dragging helper grid, every x , y pixels. array values: [x, y] code examples":
initialize draggable grid option specified.
$( ".selector" ).draggable({ grid: [50, 20] }); get or set grid option, after init.
//getter var grid = $( ".selector" ).draggable( "option", "grid" ); //setter $( ".selector" ).draggable( "option", "grid", [50, 20] ); hopefully helps you.
Comments
Post a Comment