mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Draggable demo: Fixed containment option.
This commit is contained in:
parent
509a3a673c
commit
91bf052d81
@ -71,8 +71,8 @@
|
|||||||
bottom = top + container.height();
|
bottom = top + container.height();
|
||||||
|
|
||||||
function drag( event, ui ) {
|
function drag( event, ui ) {
|
||||||
var leftDiff = ui.startOffset.left + ui.startPosition.left,
|
var leftDiff = ui.startOffset.left - ui.startPosition.left,
|
||||||
topDiff = ui.startOffset.top + ui.startPosition.top;
|
topDiff = ui.startOffset.top - ui.startPosition.top;
|
||||||
|
|
||||||
ui.position.left = Math.max( ui.position.left, left - leftDiff );
|
ui.position.left = Math.max( ui.position.left, left - leftDiff );
|
||||||
ui.position.left = Math.min( ui.position.left,
|
ui.position.left = Math.min( ui.position.left,
|
||||||
@ -87,7 +87,7 @@
|
|||||||
.bind( "drag", drag )
|
.bind( "drag", drag )
|
||||||
.one( "dragstop", function() {
|
.one( "dragstop", function() {
|
||||||
draggable.element.unbind( "drag", drag );
|
draggable.element.unbind( "drag", drag );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
@ -105,7 +105,7 @@
|
|||||||
<div class="demo">
|
<div class="demo">
|
||||||
|
|
||||||
<h3 class="docs">Constrain movement along an axis:</h3>
|
<h3 class="docs">Constrain movement along an axis:</h3>
|
||||||
|
|
||||||
<div id="draggable" class="draggable ui-widget-content">
|
<div id="draggable" class="draggable ui-widget-content">
|
||||||
<p>I can be dragged only vertically</p>
|
<p>I can be dragged only vertically</p>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user