$(".draggable").draggable({axis: 'x'});
<div 开发者_如何学Cclass="draggable">
I am draggable to left side only, and not right or up or down, the axis : x controls me to prevent up or down dragging, but make me not right too. Thanks
I solved it saving the previous left offset and comparing it with the new left offset.
var previousOffset = null;
$( "#draggable" ).draggable({
axis: 'x',
drag: function(event,ui){
if(previousOffset == null)
previousOffset = ui.offset.left;
else{
if(previousOffset < ui.offset.left)
return false;
else
previousOffset = ui.offset.left;
}
}
});
Here's working: http://jsbin.com/ubine3/2
加载中,请稍侯......
精彩评论