]> source.dussan.org Git - jquery-ui.git/commitdiff
completed reorganization of draggable demos
authorMaggie Costello Wachs <fg.maggie@gmail.com>
Thu, 15 Jan 2009 21:57:33 +0000 (21:57 +0000)
committerMaggie Costello Wachs <fg.maggie@gmail.com>
Thu, 15 Jan 2009 21:57:33 +0000 (21:57 +0000)
14 files changed:
demos/demos.css
demos/draggable/constrain-movement.html
demos/draggable/containment_iframe.html
demos/draggable/cursor-style.html [new file with mode: 0644]
demos/draggable/default.html
demos/draggable/delay-start.html [new file with mode: 0644]
demos/draggable/events.html
demos/draggable/handle.html
demos/draggable/index.html
demos/draggable/revert.html
demos/draggable/scroll.html
demos/draggable/snap-to.html
demos/draggable/sortable.html
demos/draggable/visual-feedback.html

index 708f02164f512b0caa43db6448d2a17401f91b27..a7056554654a311867cca6bf9064d7379f189522 100644 (file)
@@ -188,7 +188,10 @@ div.demo {
        font-family: "Trebuchet MS", "Arial", "Helvetica", "Verdana", "sans-serif";
 }
 
+#demo-frame div.demo h3 { clear:left; font-size:12px; font-weight:normal; padding:0 0 1em; margin:0; }
+
 div.demo-description {
+       clear:both;
        padding:12px;
        font-family: "Trebuchet MS", "Arial", "Helvetica", "Verdana", "sans-serif";
        font-size: 1.3em;
index fbfea800978296a3f937bf71e9f605091257486b..997c50af2670b5120732dc79de5114429cef45f8 100644 (file)
@@ -1,43 +1,65 @@
 <!doctype html>
 <html lang="en">
 <head>
-       <title>jQuery UI Draggable - Axis Demo</title>
+       <title>jQuery UI Draggable - Constrain movement</title>
        <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
        <script type="text/javascript" src="../../jquery-1.3.js"></script>
        <script type="text/javascript" src="../../ui/ui.core.js"></script>
        <script type="text/javascript" src="../../ui/ui.draggable.js"></script>
        <link type="text/css" href="../demos.css" rel="stylesheet" />
        <style type="text/css">
-       #draggable, #draggable2 { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 5px; }
+       .draggable { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 5px; }
+       #draggable, #draggable2 { margin-bottom:20px; }
        #draggable { cursor: n-resize; }
        #draggable2 { cursor: e-resize; }
+       #containment-wrapper { width:100%; height:150px; border:2px solid #ccc; }
        </style>
        <script type="text/javascript">
        $(function() {
                $("#draggable").draggable({ axis: 'y' });
                $("#draggable2").draggable({ axis: 'x' });
+               
+               $("#draggable3").draggable({ containment: '#containment-wrapper', scroll: false });
+               $("#draggable4").draggable({ containment: '#demo-frame' });
+               $("#draggable5").draggable({ containment: 'parent' });
+
        });
        </script>
 </head>
 <body>
 <div class="demo">
+
+<h3>Constrain movement along an axis:</h3>
        
-<div id="draggable" class="ui-widget-content">
+<div id="draggable" class="draggable ui-widget-content">
        <p>I can be dragged only vertically</p>
 </div>
 
-<div id="draggable2" class="ui-widget-content">
+<div id="draggable2" class="draggable ui-widget-content">
        <p>I can be dragged only horizontally</p>
 </div>
 
-<!-- ADD CONTAINMENT EXAMPLE -->
+<h3>or to within another DOM element:</h3>
+<div id="containment-wrapper">
+<div id="draggable3" class="draggable ui-widget-content">
+       <p>I'm contained within the box</p>
+</div>
+
+<div id="draggable4" class="draggable ui-widget-content">
+       <p>I'm contained within the box's parent</p>
+</div>
+
+<div class="draggable ui-widget-content">
+       <p id="draggable5" class="ui-widget-header">I'm contained within my parent</p>
+</div>
+</div>
 
 </div><!-- End demo -->
 
 <div class="demo-description">
 
 <p>
-Define the boundaries of the draggable area. Set the <strong>axis</strong> option to limit the draggable's path to the x- or y-axis. Or use the <strong>containment</strong> option to specify a parent DOM element or a jQuery selector, like 'document.'
+Constrain the movement of each draggable by defining the boundaries of the draggable area. Set the <strong>axis</strong> option to limit the draggable's path to the x- or y-axis, or use the <strong>containment</strong> option to specify a parent DOM element or a jQuery selector, like 'document.'
 </p>
 
 </div><!-- End demo-description -->
index c9eafdd111e2c40b35a88db0e4688d28b541e11c..7416afb1001fdad14e619a03c06288540d328eec 100644 (file)
@@ -8,7 +8,8 @@
        <script type="text/javascript" src="../../ui/ui.draggable.js"></script>
        <link type="text/css" href="../demos.css" rel="stylesheet" />
        <style type="text/css">
-       .ui-widget-content { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 5px; }
+       div.demo { padding:0; }
+       .ui-widget-content { width: 100px; height: 100px; padding: 0.5em; float: left; margin:0 10px 0 0; }
        </style>
        <script type="text/javascript">
        $(function() {
diff --git a/demos/draggable/cursor-style.html b/demos/draggable/cursor-style.html
new file mode 100644 (file)
index 0000000..03e0c5f
--- /dev/null
@@ -0,0 +1,46 @@
+<!doctype html>
+<html lang="en">
+<head>
+       <title>jQuery UI Draggable - Cursor style</title>
+       <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
+       <script type="text/javascript" src="../../jquery-1.3.js"></script>
+       <script type="text/javascript" src="../../ui/ui.core.js"></script>
+       <script type="text/javascript" src="../../ui/ui.draggable.js"></script>
+       <link type="text/css" href="../demos.css" rel="stylesheet" />
+       <style type="text/css">
+       #draggable, #draggable2, #draggable3 { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 5px; }
+       </style>
+       <script type="text/javascript">
+       $(function() {
+               $("#draggable").draggable({ cursorAt: { top: 56, left: 56 } });
+               $("#draggable2").draggable({ cursorAt: { top: -5, left: -5 } });
+               $("#draggable3").draggable({ cursorAt: { bottom: 0 } });
+       });
+       </script>
+</head>
+<body>
+<div class="demo">
+       
+<div id="draggable" class="ui-widget-content">
+       <p>I will always stick to the center (relative to the mouse)</p>
+</div>
+
+<div id="draggable2" class="ui-widget-content">
+       <p>My cursor is at left -5 and top -5</p>
+</div>
+
+<div id="draggable3" class="ui-widget-content">
+       <p>My cursor position is only controlled for the 'bottom' value</p>
+</div>
+
+</div><!-- End demo -->
+
+<div class="demo-description">
+
+<p>
+Position the cursor while dragging the object. By default the cursor appears in the center of the dragged object; use the <strong>cursorAt</strong> option to specify another location relative to the draggable (specify a pixel value from the top, right, bottom, and/or left).  <!-- Customize the cursor's appearance by supplying the <strong>cursor</strong> option with a valid CSS cursor value: default, move, pointer, crosshair, etc. -->
+</p>
+
+</div><!-- End demo-description -->
+</body>
+</html>
index b7425819c79f911cbdb1dfc628913fc3a46f4afa..0c219d58debd891146948e6c7fdfccb9cd69ee7b 100644 (file)
@@ -1,7 +1,7 @@
 <!doctype html>
 <html lang="en">
 <head>
-       <title>jQuery UI Draggable - Default Demo</title>
+       <title>jQuery UI Draggable - Default functionality</title>
        <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
        <script type="text/javascript" src="../../jquery-1.3.js"></script>
        <script type="text/javascript" src="../../ui/ui.core.js"></script>
@@ -29,7 +29,7 @@
 <div class="demo-description">
 
 <p>
-The easiest way to make an element draggable. Hold down the mouse and drag it around.
+Enable draggable functionality on any DOM element. Move the draggable object by clicking on it with the mouse and dragging it anywhere within the viewport.
 </p>
 
 </div><!-- End demo-description -->
diff --git a/demos/draggable/delay-start.html b/demos/draggable/delay-start.html
new file mode 100644 (file)
index 0000000..66d3e48
--- /dev/null
@@ -0,0 +1,41 @@
+<!doctype html>
+<html lang="en">
+<head>
+       <title>jQuery UI Draggable - Delay start</title>
+       <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
+       <script type="text/javascript" src="../../jquery-1.3.js"></script>
+       <script type="text/javascript" src="../../ui/ui.core.js"></script>
+       <script type="text/javascript" src="../../ui/ui.draggable.js"></script>
+       <link type="text/css" href="../demos.css" rel="stylesheet" />
+       <style type="text/css">
+       #draggable, #draggable2 { width: 120px; height: 120px; padding: 0.5em; float: left; margin: 5px; }
+       </style>
+       <script type="text/javascript">
+       $(function() {
+               $("#draggable").draggable({ distance: 20 });
+               $("#draggable2").draggable({ delay: 1000 });
+       });
+       </script>
+</head>
+<body>
+<div class="demo">
+       
+<div id="draggable" class="ui-widget-content">
+       <p>Only if you drag me by 20 pixels, the dragging will start</p>
+</div>
+
+<div id="draggable2" class="ui-widget-content">
+       <p>Regardless of the distance, you have to drag and wait for 1000ms before dragging starts</p>
+</div>
+
+</div><!-- End demo -->
+
+<div class="demo-description">
+
+<p>
+Delay the start of dragging for a number of milliseconds with the <strong>delay</strong> option; prevent dragging until the cursor is held down and dragged a specifed number of pixels with the <strong>distance</strong> option. 
+</p>
+
+</div><!-- End demo-description -->
+</body>
+</html>
index 98f2065a32fd73f0f9c98ae4c4eaa2b24d446ddc..8d836bdbc5960bf37cd07469fb10e87000fed377 100644 (file)
@@ -1,7 +1,7 @@
 <!doctype html>
 <html lang="en">
 <head>
-       <title>jQuery UI Draggable - Events Demo</title>
+       <title>jQuery UI Draggable - Events</title>
        <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
        <script type="text/javascript" src="../../jquery-1.3.js"></script>
        <script type="text/javascript" src="../../ui/ui.core.js"></script>
@@ -65,7 +65,7 @@
 <div class="demo-description">
 
 <p>
-<!-- Add description here -->
+Layer functionality onto the draggable using the <strong>start</strong>, <strong>drag</strong>, and <strong>stop</strong> events.  Start is fired at the start of the drag; drag during the drag; and stop when dragging stops.
 </p>
 
 </div><!-- End demo-description -->
index ea53c09b8deb5166c4b4c6c36c00f8daafa3a520..bbaf3431bec7b197585bc44aab08ae808c9cc26d 100644 (file)
@@ -1,19 +1,20 @@
 <!doctype html>
 <html lang="en">
 <head>
-       <title>jQuery UI Draggable - Handle Demo</title>
+       <title>jQuery UI Draggable - Handles</title>
        <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
        <script type="text/javascript" src="../../jquery-1.3.js"></script>
        <script type="text/javascript" src="../../ui/ui.core.js"></script>
        <script type="text/javascript" src="../../ui/ui.draggable.js"></script>
        <link type="text/css" href="../demos.css" rel="stylesheet" />
        <style type="text/css">
-       #draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 5px; }
+       #draggable, #draggable2 { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 5px; }
        #draggable p { cursor: move; }
        </style>
        <script type="text/javascript">
        $(function() {
                $("#draggable").draggable({ handle: 'p' });
+               $("#draggable2").draggable({ cancel: "p.ui-widget-header" });
        });
        </script>
 </head>
        <p class="ui-widget-header">I can be dragged only by this handle</p>
 </div>
 
+<div id="draggable2" class="ui-widget-content">
+       <p>You can drag me around&hellip;</p>
+       <p class="ui-widget-header">&hellip;but you can't drag me by this handle.</p>
+</div>
+
 <!-- ADD CANCEL DEMO -->
 
 </div><!-- End demo -->
 
 <div class="demo-description">
 
-<p>
-<!-- Add description here -->
-</p>
+<p>Allow dragging only when the cursor is over a specific part of the draggable.  Use the <strong>handle</strong> option to specify the jQuery selector of an element (or group of elements) used to drag the object.</p>
+<p>Or prevent dragging when the cursor is over a specific element (or group of elements) within the draggable.  Use the <strong>cancel</strong> option to specify a jQuery selector over which to "cancel" draggable functionality.</p>
 
 </div><!-- End demo-description -->
 </body>
index d4c9271930b475050fe438965994c1c9b7ba710a..e5eef219a683babcdc2778348f7f79e4797841d8 100644 (file)
@@ -13,7 +13,7 @@
                <li><a href="events.html">Events</a></li>
                <li><a href="constrain-movement.html">Constrain movement</a></li>
                <li><a href="delay-start.html">Delay start</a></li>
-               <li><a href="snap-to.html">Snap to grid or element</a></li>
+               <li><a href="snap-to.html">Snap to element or grid</a></li>
                <li><a href="scroll.html">Auto-scroll</a></li>
                <li><a href="revert.html">Revert position</a></li>
                <li><a href="visual-feedback.html">Visual feedback</a></li>
index 7a43c4f46365bbea4222c1dd65b00e09f7514781..15d452020f9d46393af1635ba8c691a6b5a2a499 100644 (file)
@@ -1,7 +1,7 @@
 <!doctype html>
 <html lang="en">
 <head>
-       <title>jQuery UI Draggable - Revert Demo</title>
+       <title>jQuery UI Draggable - Revert position</title>
        <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
        <script type="text/javascript" src="../../jquery-1.3.js"></script>
        <script type="text/javascript" src="../../ui/ui.core.js"></script>
@@ -33,7 +33,7 @@
 <div class="demo-description">
 
 <p>
-<!-- Add description here -->
+Return the draggable (or it's helper) to its original location when dragging stops with the boolean <strong>revert</strong> option.
 </p>
 
 </div><!-- End demo-description -->
index 371cec7472317d1dbbfe2a582f93356960b23f87..f94dd6609ab4b335d167836e4d9fa1e08314b77c 100644 (file)
@@ -1,7 +1,7 @@
 <!doctype html>
 <html lang="en">
 <head>
-       <title>jQuery UI Draggable - Scroll Demo</title>
+       <title>jQuery UI Draggable - Auto-scroll</title>
        <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
        <script type="text/javascript" src="../../jquery-1.3.js"></script>
        <script type="text/javascript" src="../../ui/ui.core.js"></script>
@@ -40,7 +40,7 @@
 <div class="demo-description">
 
 <p>
-<!-- Add description here -->
+Automatically scroll the document when the draggable is moved beyond the viewport. Set the <strong>scroll</strong> option to true to enable auto-scrolling, and fine-tune when scrolling is triggered and its speed with the <strong>scrollSensitivity</strong> and <strong>scrollSpeed</strong> options.
 </p>
 
 </div><!-- End demo-description -->
index 0f9c9a91d0d2ca9c9b1101b1c3f019e2743382f1..9d8a26b91f98f49e50f56d06416d6c898324a41f 100644 (file)
@@ -1,14 +1,14 @@
 <!doctype html>
 <html lang="en">
 <head>
-       <title>jQuery UI Draggable - Snap Demo</title>
+       <title>jQuery UI Draggable - Snap to element or grid</title>
        <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
        <script type="text/javascript" src="../../jquery-1.3.js"></script>
        <script type="text/javascript" src="../../ui/ui.core.js"></script>
        <script type="text/javascript" src="../../ui/ui.draggable.js"></script>
        <link type="text/css" href="../demos.css" rel="stylesheet" />
        <style type="text/css">
-       #draggable, #draggable2, #draggable3, #draggable4, #draggable5 { width: 100px; height: 80px; padding: 5px; float: left; margin: 5px; font-size: .9em; }
+       .draggable { width: 90px; height: 80px; padding: 5px; float: left; margin: 5px; font-size: .9em; }
        .ui-widget-header p, .ui-widget-content p { margin: 0; }
        #snaptarget { height: 140px; }
        </style>
@@ -17,8 +17,8 @@
                $("#draggable").draggable({ snap: true });
                $("#draggable2").draggable({ snap: '.ui-widget-header' });
                $("#draggable3").draggable({ snap: '.ui-widget-header', snapMode: 'outer' });
-               $("#draggable4").draggable({ snap: '.ui-widget-header', snapMode: 'inner' });
-               $("#draggable5").draggable({ snap: '.ui-widget-header', snapTolerance: 50 });
+               $("#draggable4").draggable({ grid: [20,20] });
+               $("#draggable5").draggable({ grid: [80, 80] });
        });
        </script>
 </head>
 
 <br clear="both" />
 
-<div id="draggable" class="ui-widget-content">
+<div id="draggable" class="draggable ui-widget-content">
        <p>Default (snap: true), snaps to all other draggable elements</p>
 </div>
 
-<div id="draggable2" class="ui-widget-content">
+<div id="draggable2" class="draggable ui-widget-content">
        <p>I only snap to the big box</p>
 </div>
 
-<div id="draggable3" class="ui-widget-content">
+<div id="draggable3" class="draggable ui-widget-content">
        <p>I only snap to the outer edges of the bix box</p>
 </div>
 
-<div id="draggable4" class="ui-widget-content">
-       <p>I only snap to the inner edges of the big box</p>
+<div id="draggable4" class="draggable ui-widget-content">
+       <p>I snap to a 20 x 20 grid</p>
 </div>
 
-<div id="draggable5" class="ui-widget-content">
-       <p>I also snap to the big box but I'm very sticky because I have a high tolerance</p>
+<div id="draggable5" class="draggable ui-widget-content">
+       <p>I snap to a 80 x 80 grid</p>
 </div>
 
-
-<!-- ADD GRID EXAMPLE -->
-
 </div><!-- End demo -->
 
 <div class="demo-description">
 
-<p>
-<!-- Add description here -->
-</p>
+<p>Snap the draggable to the inner or outer boundaries of a DOM element.  Use the <strong>snap</strong>, <strong>snapMode</strong> (inner, outer, both), and <strong>snapTolerance</strong> (distance in pixels the draggable must be from the element when snapping is invoked) options. </p>
+
+<p>Or snap the draggable to a grid.  Set the dimensions of grid cells (height and width in pixels) with the <strong>grid</strong> option.</p>
 
 </div><!-- End demo-description -->
 
index 2649807b7272bbbd371b1c94518e66b2ed4119b4..459434e093857202f39339006adb406953918626 100644 (file)
@@ -1,7 +1,7 @@
 <!doctype html>
 <html lang="en">
 <head>
-       <title>jQuery UI Draggable - Sortable Demo</title>
+       <title>jQuery UI Draggable + Sortable</title>
        <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
        <script type="text/javascript" src="../../jquery-1.3.js"></script>
        <script type="text/javascript" src="../../ui/ui.core.js"></script>
@@ -45,7 +45,7 @@
 <div class="demo-description">
 
 <p>
-<!-- Add description here -->
+Draggables are built to interact seamlessly with <a href="#">sortables</a>.
 </p>
 
 </div><!-- End demo-description -->
index 3335605679b8953c7f9097311d667d6323b63b87..23e342e92890791a087c2200b780d4ddcdf10574 100644 (file)
@@ -1,19 +1,22 @@
 <!doctype html>
 <html lang="en">
 <head>
-       <title>jQuery UI Draggable - Helper Demo</title>
+       <title>jQuery UI Draggable - Visual feedback</title>
        <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
        <script type="text/javascript" src="../../jquery-1.3.js"></script>
        <script type="text/javascript" src="../../ui/ui.core.js"></script>
        <script type="text/javascript" src="../../ui/ui.draggable.js"></script>
        <link type="text/css" href="../demos.css" rel="stylesheet" />
        <style type="text/css">
-       #draggable, #draggable2, #draggable3 { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 5px; }
+       #draggable, #draggable2, #draggable3, #set div { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 5px; }
+       #draggable, #draggable2, #draggable3 { margin-bottom:20px; }
+       #set { clear:both; float:left; width: 368px; height: 120px; }
+       p { clear:both; margin:0; padding:1em 0; }
        </style>
        <script type="text/javascript">
        $(function() {
                $("#draggable").draggable({ helper: 'original' });
-               $("#draggable2").draggable({ helper: 'clone' });
+               $("#draggable2").draggable({ opacity: 0.7, helper: 'clone' });
                $("#draggable3").draggable({
                        cursor: 'move',
                        cursorAt: { top: -12, left: -20 },
                                return $('<div class="ui-widget-header">I\'m a custom helper</div>');
                        }
                });
+               $("#set div").draggable({ stack: { group: '#set div', min: 1 } });
        });
        </script>
 </head>
 <body>
 <div class="demo">
 
+<h3>With helpers:</h3>
+
 <div id="draggable" class="ui-widget-content">
        <p>Original</p>
 </div>
 
 <div id="draggable2" class="ui-widget-content">
-       <p>Clone</p>
+       <p>Semi-transparent clone</p>
 </div>
 
 <div id="draggable3" class="ui-widget-content">
        <p>Custom helper (in combination with cursorAt)</p>
 </div>
 
-<!-- ADD EXAMPLES FOR OPACITY + ZINDEX/STACK -->
+<h3>Stacked:</h3>
+<div id="set">
+       <div class="ui-widget-content">
+               <p>We are draggables..</p>
+       </div>
+
+       <div class="ui-widget-content">
+               <p>..whose z-indexes are controlled automatically..</p>
+       </div>
+
+       <div class="ui-widget-content">
+               <p>..with the stack option.</p>
+       </div>
+</div>
 
 </div><!-- End demo -->
 
 <div class="demo-description">
 
-<p>
-<!-- Add description here -->
-</p>
+<p>Provide feedback to users as they drag an object in the form of a helper. The <strong>helper</strong> option accepts the values 'original' (the draggable object moves with the cursor), 'clone' (a duplicate of the draggable moves with the cursor), or a function that returns a DOM element (that element is shown near the cursor during drag). Control the helper's transparency with the <strong>opacity</strong> option.</p>
+
+<p>To clarify which draggable is in play, bring the draggable in motion to front. Use the <strong>zindex</strong> option to set a higher z-index for the helper, if in play, or use the <strong>stack</strong> option to ensure that the last item dragged will appear on top of others in the same group on drag stop.</p>
 
 </div><!-- End demo-description -->
 </body>