| 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | <title>jQuery UI Draggable - Visual feedback</title> |
| 7 | <link rel="stylesheet" href="../../themes/base/all.css"> |
| 8 | <link rel="stylesheet" href="../demos.css"> |
| 9 | <style> |
| 10 | #draggable, #draggable2, #draggable3, #set div { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 0 10px 10px 0; } |
| 11 | #draggable, #draggable2, #draggable3 { margin-bottom:20px; } |
| 12 | #set { clear:both; float:left; width: 368px; height: 120px; } |
| 13 | p { clear:both; margin:0; padding:1em 0; } |
| 14 | </style> |
| 15 | <script src="../../external/requirejs/require.js"></script> |
| 16 | <script src="../bootstrap.js"> |
| 17 | $( "#draggable" ).draggable({ helper: "original" }); |
| 18 | $( "#draggable2" ).draggable({ opacity: 0.7, helper: "clone" }); |
| 19 | $( "#draggable3" ).draggable({ |
| 20 | cursor: "move", |
| 21 | cursorAt: { top: -12, left: -20 }, |
| 22 | helper: function( event ) { |
| 23 | return $( "<div class='ui-widget-header'>I'm a custom helper</div>" ); |
| 24 | } |
| 25 | }); |
| 26 | $( "#set div" ).draggable({ stack: "#set div" }); |
| 27 | </script> |
| 28 | </head> |
| 29 | <body> |
| 30 | |
| 31 | <h3 class="docs">With helpers:</h3> |
| 32 | |
| 33 | <div id="draggable" class="ui-widget-content"> |
| 34 | <p>Original</p> |
| 35 | </div> |
| 36 | |
| 37 | <div id="draggable2" class="ui-widget-content"> |
| 38 | <p>Semi-transparent clone</p> |
| 39 | </div> |
| 40 | |
| 41 | <div id="draggable3" class="ui-widget-content"> |
| 42 | <p>Custom helper (in combination with cursorAt)</p> |
| 43 | </div> |
| 44 | |
| 45 | <h3 class="docs">Stacked:</h3> |
| 46 | <div id="set"> |
| 47 | <div class="ui-widget-content"> |
| 48 | <p>We are draggables..</p> |
| 49 | </div> |
| 50 | |
| 51 | <div class="ui-widget-content"> |
| 52 | <p>..whose z-indexes are controlled automatically..</p> |
| 53 | </div> |
| 54 | |
| 55 | <div class="ui-widget-content"> |
| 56 | <p>..with the stack option.</p> |
| 57 | </div> |
| 58 | </div> |
| 59 | |
| 60 | <div class="demo-description"> |
| 61 | <p>Provide feedback to users as they drag an object in the form of a helper. The <code>helper</code> 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 <code>opacity</code> option.</p> |
| 62 | <p>To clarify which draggable is in play, bring the draggable in motion to front. Use the <code>zIndex</code> option to set a higher z-index for the helper, if in play, or use the <code>stack</code> option to ensure that the last item dragged will appear on top of others in the same group on drag stop.</p> |
| 63 | </div> |
| 64 | </body> |
| 65 | </html> |