i'm trying stop dragging children div when position equal or higher parent position:
$( ".content" ).draggable({ axis: "x", drag: function( event, ui ) { var wrapper = $(".wrapper").offset(); var pos = ui.helper.offset(); $(".content").val(pos.left - wrapper.left); if ($(".content").val() >= 0){ $( ".content" ).draggable( "option", "disabled", true ); } } });
but div stops when release mouse. need stop while being dragged.
solved
wrapper = $('.wrapper'); content = $('.content'); wrapperwidth = wrapper.width(); contentwidth = content.width(); startwrapper = wrapper.offset().left; endwrapper = wrapper.offset().left + wrapperwidth - contentwidth; content.draggable({ axis: "x", cursor: "e-resize", containment : [endwrapper,0,startwrapper,0] });
i believe draggable has behavior want. use containment option array syntax instead of interrupting drag event.
Comments
Post a Comment