You use the containment option and check if the image supports within its borders, it allows you to:
Drag constants within the specified element or region.
Several types are supported:
Selector The draggable element will be contained in the bounding box of the first element found by the selector. If no items are found, no restriction will be set.
Item . The draggable element will be contained in the bounding box of this element. Line: Possible values: "parent", "document", "window".
Array : an array defining a bounding rectangle in the form [x1, y1, x2, y2].
the code:
$(document).ready(function () { $(".cover_image").draggable({ containment: [ $(window).width() - $(".cover_image").width(), $(window).height() - $(".cover_image").height(), 0, 0] }); });
Demo: http://jsfiddle.net/8ZBPA/
source share