| 1 |
<!doctype html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<title>jQuery UI Draggable - Delay start</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 { width: 120px; height: 120px; padding: 0.5em; float: left; margin: 0 10px 10px 0; } |
| 12 |
</style> |
| 13 |
<script type="text/javascript"> |
| 14 |
$(function() { |
| 15 |
$("#draggable").draggable({ distance: 20 }); |
| 16 |
$("#draggable2").draggable({ delay: 1000 }); |
| 17 |
$(".ui-draggable").disableSelection(); |
| 18 |
}); |
| 19 |
</script> |
| 20 |
</head> |
| 21 |
<body> |
| 22 |
<div class="demo"> |
| 23 |
|
| 24 |
<div id="draggable" class="ui-widget-content"> |
| 25 |
<p>Only if you drag me by 20 pixels, the dragging will start</p> |
| 26 |
</div> |
| 27 |
|
| 28 |
<div id="draggable2" class="ui-widget-content"> |
| 29 |
<p>Regardless of the distance, you have to drag and wait for 1000ms before dragging starts</p> |
| 30 |
</div> |
| 31 |
|
| 32 |
</div><!-- End demo --> |
| 33 |
|
| 34 |
<div class="demo-description"> |
| 35 |
|
| 36 |
<p> |
| 37 |
Delay the start of dragging for a number of milliseconds with the <code>delay</code> option; prevent dragging until the cursor is held down and dragged a specifed number of pixels with the <code>distance</code> option. |
| 38 |
</p> |
| 39 |
|
| 40 |
</div><!-- End demo-description --> |
| 41 |
</body> |
| 42 |
</html> |
| 43 |
|