Hello,
i'm trying to the authorize to drag out an object only on the right or bottom side of his containment and cannot do it properly whitout stop dragging the element.
My code:
<!DOCTYPE html>
<html>
<head>
<style>
#parent { height: 500px; width: 500px; border: 1px black solid; }
#images { height: 100px; width: 100px; background-color:orange; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.js"></script>
</head>
<body>
<div id="parent">
<div id="images"></div>
</div>
<script>
$(document).ready(function() {
$("#images").draggable({
containment: $("#parent"),
drag: function(event, ui) {
var helper = ui.helper, pos = ui.position;
if(pos.left + parseInt(helper.outerWidth(), 10) == parseInt($("#parent").css("width"), 10)) {
$("#parent").animate({width: "+=100"});
}
if(pos.top + parseInt(helper.outerHeight(), 10) == parseInt($("#parent").css("height"), 10)) {
$("#parent").animate({height: "+=100"});
}
}
});
});
</script>
</body>
</html>
Have you an idea how about refreshing the containment size in order to continue dragging on the right or bottom side ?
Thanks !