Hello everyone at SO! Can somebody tell me how to display an alert when containment limits are reached?
Thanks in advance.
Hello everyone at SO! Can somebody tell me how to display an alert when containment limits are reached?
Thanks in advance.
You can check that the position isn't changing when the drag event is occuring, like this:
var position = {};
$("#draggable").draggable({
containment: 'document',
drag: function(event, ui) {
if(position.top == ui.position.top && position.left == ui.position.left) {
alert("Constrained");
return false;
}
position = ui.position;
}
});