/[projects]/misc/horsensspejder-web/jquery/jquery-ui-1.10.3/demos/draggable/constrain-movement.html
ViewVC logotype

Annotation of /misc/horsensspejder-web/jquery/jquery-ui-1.10.3/demos/draggable/constrain-movement.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (hide annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 4 months ago) by torben
File MIME type: text/html
File size: 2068 byte(s)
initial import
1 torben 2125 <!doctype html>
2     <html lang="en">
3     <head>
4     <meta charset="utf-8">
5     <title>jQuery UI Draggable - Constrain movement</title>
6     <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
7     <script src="../../jquery-1.9.1.js"></script>
8     <script src="../../ui/jquery.ui.core.js"></script>
9     <script src="../../ui/jquery.ui.widget.js"></script>
10     <script src="../../ui/jquery.ui.mouse.js"></script>
11     <script src="../../ui/jquery.ui.draggable.js"></script>
12     <link rel="stylesheet" href="../demos.css">
13     <style>
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     h3 { clear: left; }
20     </style>
21     <script>
22     $(function() {
23     $( "#draggable" ).draggable({ axis: "y" });
24     $( "#draggable2" ).draggable({ axis: "x" });
25    
26     $( "#draggable3" ).draggable({ containment: "#containment-wrapper", scroll: false });
27     $( "#draggable5" ).draggable({ containment: "parent" });
28     });
29     </script>
30     </head>
31     <body>
32    
33     <h3>Constrain movement along an axis:</h3>
34    
35     <div id="draggable" class="draggable ui-widget-content">
36     <p>I can be dragged only vertically</p>
37     </div>
38    
39     <div id="draggable2" class="draggable ui-widget-content">
40     <p>I can be dragged only horizontally</p>
41     </div>
42    
43     <h3>Or to within another DOM element:</h3>
44     <div id="containment-wrapper">
45     <div id="draggable3" class="draggable ui-widget-content">
46     <p>I'm contained within the box</p>
47     </div>
48    
49     <div class="draggable ui-widget-content">
50     <p id="draggable5" class="ui-widget-header">I'm contained within my parent</p>
51     </div>
52     </div>
53    
54     <div class="demo-description">
55     <p>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.'</p>
56     </div>
57     </body>
58     </html>

  ViewVC Help
Powered by ViewVC 1.1.20