I have a jQuery draggable element which should allow itself to be dragged up, down, or right, but not left.
Is there any way I can accomplish this?
I realize it's possible to use revert
, check its position after being dragged, and bring it back to the starting position; however, I would like to disabled left-direciton dragging from the start.
This is my current code:
$(elem).draggable({
cursor: "move",
scroll: false,
addClasses: true,
start: function(e, ui) {
//I can calculate the starting position here
},
stop: function(e, ui) {
//some stuff happens here, not relevant
}
});
My idea is to get the starting position and then somehow check the position while the dragging is going on dynamically, compare it to the starting one, and if current.left
Is this possible?
If not, then I guess I'll have to perform the check within the stop
section of the code, and revert to the original position from there.
Note that I can't change the size/position of the parent container, which is full-screen. Also, if I move the draggable element right and drop it, I still should not be able to drag it left from the new position.