jQuery UI draggable Options delay

To control draggable elements a dealy start.
$("#eleID").draggable({delay: 100});
Try to set delay value and drag around squares to see .
ExampleJquery ui draggable options delay
Source Code Expand
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://www.pureexample.com/js/lib/jquery.ui.touch-punch.min.js"></script>


<!-- CSS -->
<style type="text/css">
.grid {
    width: 100px;
    height: 80px;
    line-height: 80px;
    margin: 2px;
    border: 1px solid black;
    background-color: lightgreen;
    text-align: center;
    float: left;
    margin: 2px;
    padding: 2px;
    border-radius: 3px;
}
</style>


<!-- Javascript -->
<script>
$(function () {
	$("#g1").draggable({
		delay: $("#delayvalue").val()
	});

	$("#delayvalue").keyup(function () {
		$("#g1").draggable("option", "delay", $("#delayvalue").val());
	});
});
</script>

<!-- HTML -->
<div id="container" style="float:left;width:500px;">
    <div id="g1" class="grid">dragging delay</div>
    <div style="clear:both"></div>
    set delay : <input id="delayvalue" type="text" value="100"> (milliseconds)
</div>


comments powered by Disqus