I\'m creating an interface to allow a user to zoom in on an image and drag the zoomed version around within a clipping mask div.
I have a div 200px by 200px
$(this).draggable({
drag: function(event, ui) {
if (ui.position.top > 0) {
ui.position.top = 0;
}
var maxtop = ui.helper.parent().height() - ui.helper.height();
if ( ui.position.top < maxtop) {
ui.position.top = maxtop;
}
if ( ui.position.left > 0) {
ui.position.left = 0;
}
var maxleft = ui.helper.parent().width() - ui.helper.width();
if ( ui.position.left < maxleft) {
ui.position.left = maxleft;
}
}
});