PluginProbe
RSVP and Event Management / 1.1.0
RSVP and Event Management v1.1.0
trunk 0.5.0 0.6.0 0.7.0 0.8.0 0.9.0 0.9.5 1.0.0 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.5.0 1.6.0 1.6.1 1.6.2 1.6.5 1.7.0 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 All 136 releases
rsvp / jquery-ui-1.7.2.custom / development-bundle / demos / draggable / constrain-movement.html

constrain-movement.html in RSVP and Event Management 1.1.0, at jquery-ui-1.7.2.custom/development-bundle/demos/draggable/constrain-movement.html

68 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <!doctype html>
2 <html lang="en">
3 <head>
4 <title>jQuery UI Draggable - Constrain movement</title>
5 <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
6 <script type="text/javascript" src="../../jquery-1.3.2.js"></script>
7 <script type="text/javascript" src="../../ui/ui.core.js"></script>
8 <script type="text/javascript" src="../../ui/ui.draggable.js"></script>
9 <link type="text/css" href="../demos.css" rel="stylesheet" />
10 <style type="text/css">
11 .draggable { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 0 10px 10px 0; }
12 #draggable, #draggable2 { margin-bottom:20px; }
13 #draggable { cursor: n-resize; }
14 #draggable2 { cursor: e-resize; }
15 #containment-wrapper { width: 95%; height:150px; border:2px solid #ccc; padding: 10px;}
16 </style>
17 <script type="text/javascript">
18 $(function() {
19 $("#draggable").draggable({ axis: 'y' });
20 $("#draggable2").draggable({ axis: 'x' });
21
22 $("#draggable3").draggable({ containment: '#containment-wrapper', scroll: false });
23 $("#draggable4").draggable({ containment: '#demo-frame' });
24 $("#draggable5").draggable({ containment: 'parent' });
25
26 });
27 </script>
28 </head>
29 <body>
30 <div class="demo">
31
32 <h3 class="docs">Constrain movement along an axis:</h3>
33
34 <div id="draggable" class="draggable ui-widget-content">
35 <p>I can be dragged only vertically</p>
36 </div>
37
38 <div id="draggable2" class="draggable ui-widget-content">
39 <p>I can be dragged only horizontally</p>
40 </div>
41
42 <h3 class="docs">Or to within another DOM element:</h3>
43 <div id="containment-wrapper">
44 <div id="draggable3" class="draggable ui-widget-content">
45 <p>I'm contained within the box</p>
46 </div>
47
48 <div id="draggable4" class="draggable ui-widget-content">
49 <p>I'm contained within the box's parent</p>
50 </div>
51
52 <div class="draggable ui-widget-content">
53 <p id="draggable5" class="ui-widget-header">I'm contained within my parent</p>
54 </div>
55 </div>
56
57 </div><!-- End demo -->
58
59 <div class="demo-description">
60
61 <p>
62 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.'
63 </p>
64
65 </div><!-- End demo-description -->
66 </body>
67 </html>
68