| 1 |
<!doctype html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<title>jQuery UI Draggable - Visual feedback</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, #draggable2, #draggable3, #set div { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 0 10px 10px 0; } |
| 12 |
#draggable, #draggable2, #draggable3 { margin-bottom:20px; } |
| 13 |
#set { clear:both; float:left; width: 368px; height: 120px; } |
| 14 |
p { clear:both; margin:0; padding:1em 0; } |
| 15 |
</style> |
| 16 |
<script type="text/javascript"> |
| 17 |
$(function() { |
| 18 |
$("#draggable").draggable({ helper: 'original' }); |
| 19 |
$("#draggable2").draggable({ opacity: 0.7, helper: 'clone' }); |
| 20 |
$("#draggable3").draggable({ |
| 21 |
cursor: 'move', |
| 22 |
cursorAt: { top: -12, left: -20 }, |
| 23 |
helper: function(event) { |
| 24 |
return $('<div class="ui-widget-header">I\'m a custom helper</div>'); |
| 25 |
} |
| 26 |
}); |
| 27 |
$("#set div").draggable({ stack: { group: '#set div', min: 1 } }); |
| 28 |
}); |
| 29 |
</script> |
| 30 |
</head> |
| 31 |
<body> |
| 32 |
<div class="demo"> |
| 33 |
|
| 34 |
<h3 class="docs">With helpers:</h3> |
| 35 |
|
| 36 |
<div id="draggable" class="ui-widget-content"> |
| 37 |
<p>Original</p> |
| 38 |
</div> |
| 39 |
|
| 40 |
<div id="draggable2" class="ui-widget-content"> |
| 41 |
<p>Semi-transparent clone</p> |
| 42 |
</div> |
| 43 |
|
| 44 |
<div id="draggable3" class="ui-widget-content"> |
| 45 |
<p>Custom helper (in combination with cursorAt)</p> |
| 46 |
</div> |
| 47 |
|
| 48 |
<h3 class="docs">Stacked:</h3> |
| 49 |
<div id="set"> |
| 50 |
<div class="ui-widget-content"> |
| 51 |
<p>We are draggables..</p> |
| 52 |
</div> |
| 53 |
|
| 54 |
<div class="ui-widget-content"> |
| 55 |
<p>..whose z-indexes are controlled automatically..</p> |
| 56 |
</div> |
| 57 |
|
| 58 |
<div class="ui-widget-content"> |
| 59 |
<p>..with the stack option.</p> |
| 60 |
</div> |
| 61 |
</div> |
| 62 |
|
| 63 |
</div><!-- End demo --> |
| 64 |
|
| 65 |
<div class="demo-description"> |
| 66 |
|
| 67 |
<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> |
| 68 |
|
| 69 |
<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> |
| 70 |
|
| 71 |
</div><!-- End demo-description --> |
| 72 |
</body> |
| 73 |
</html> |
| 74 |
|