定义和用法
通过 delay 选项设置延迟开始拖拽的毫秒数。通过 distance 选项设置光标被按下且拖拽指定像素后才允许拖拽
示例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>jQuery UI 拖动(Draggable) - 延迟开始</title>
<link rel="stylesheet" href="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.css">
<style>
#draggable1,#draggable2{
width: 120px;
height: 120px;
padding: 0.5em;
float: left;
margin: 0 10px 10px 0;
}
</style>
</head>
<body>
<div id="draggable1" class="ui-widget-content">
<p>只有把我拖拽了 100 像素后,拖拽才开始</p>
</div>
<div id="draggable2" class="ui-widget-content">
<p>不管 distance 是多少,您都必须拖拽并等待 1000ms 后拖拽才开始</p>
</div>
<script src="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/external/jquery/jquery.js" type="text/javascript" ></script>
<script src="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
<script>
//100表示像素
$("#draggable1").draggable({
distance:100
});
//1000表示1000豪秒,也就是1秒
$("#draggable2").draggable({
delay:1000
});
</script>
</body>
</html>
输出
本文转自 素颜猪 51CTO博客,原文链接:http://blog.51cto.com/suyanzhu/1898441
