client/player/development-bundle/demos/draggable/constrain-movement.html
changeset 1 436d4791d7ac
equal deleted inserted replaced
0:ecdfc63274bf 1:436d4791d7ac
       
     1 <!DOCTYPE html>
       
     2 <html lang="en">
       
     3 <head>
       
     4 	<meta charset="UTF-8" />
       
     5 	<title>jQuery UI Draggable - Constrain movement</title>
       
     6 	<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
       
     7 	<script type="text/javascript" src="../../jquery-1.4.2.js"></script>
       
     8 	<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
       
     9 	<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
       
    10 	<script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script>
       
    11 	<script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script>
       
    12 	<link type="text/css" href="../demos.css" rel="stylesheet" />
       
    13 	<style type="text/css">
       
    14 	.draggable { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 0 10px 10px 0; }
       
    15 	#draggable, #draggable2 { margin-bottom:20px; }
       
    16 	#draggable { cursor: n-resize; }
       
    17 	#draggable2 { cursor: e-resize; }
       
    18 	#containment-wrapper { width: 95%; height:150px; border:2px solid #ccc; padding: 10px;}
       
    19 	</style>
       
    20 	<script type="text/javascript">
       
    21 	$(function() {
       
    22 		$("#draggable").draggable({ axis: 'y' });
       
    23 		$("#draggable2").draggable({ axis: 'x' });
       
    24 		
       
    25 		$("#draggable3").draggable({ containment: '#containment-wrapper', scroll: false });
       
    26 		$("#draggable4").draggable({ containment: '#demo-frame' });
       
    27 		$("#draggable5").draggable({ containment: 'parent' });
       
    28 
       
    29 	});
       
    30 	</script>
       
    31 </head>
       
    32 <body>
       
    33 <div class="demo">
       
    34 
       
    35 <h3 class="docs">Constrain movement along an axis:</h3>
       
    36 	
       
    37 <div id="draggable" class="draggable ui-widget-content">
       
    38 	<p>I can be dragged only vertically</p>
       
    39 </div>
       
    40 
       
    41 <div id="draggable2" class="draggable ui-widget-content">
       
    42 	<p>I can be dragged only horizontally</p>
       
    43 </div>
       
    44 
       
    45 <h3 class="docs">Or to within another DOM element:</h3>
       
    46 <div id="containment-wrapper">
       
    47 <div id="draggable3" class="draggable ui-widget-content">
       
    48 	<p>I'm contained within the box</p>
       
    49 </div>
       
    50 
       
    51 <div id="draggable4" class="draggable ui-widget-content">
       
    52 	<p>I'm contained within the box's parent</p>
       
    53 </div>
       
    54 
       
    55 <div class="draggable ui-widget-content">
       
    56 	<p id="draggable5" class="ui-widget-header">I'm contained within my parent</p>
       
    57 </div>
       
    58 </div>
       
    59 
       
    60 </div><!-- End demo -->
       
    61 
       
    62 <div class="demo-description">
       
    63 
       
    64 <p>
       
    65 Constrain the movement of each draggable by defining the boundaries of the draggable area. Set the <code>axis</code> option to limit the draggable's path to the x- or y-axis, or use the <code>containment</code> option to specify a parent DOM element or a jQuery selector, like 'document.'
       
    66 </p>
       
    67 
       
    68 </div><!-- End demo-description -->
       
    69 </body>
       
    70 </html>