【发布时间】:2016-12-30 23:49:54
【问题描述】:
我有一个使用 jquery 的可拖动 DOM 元素。
如果客户端在没有移动的情况下单击它,则不会调用可拖动开始,并且它的行为就像它不是可拖动的一样。
当客户端单击它并将鼠标移开 1 像素并按住不放时,拖动开始。触发事件,应用类等...
有没有办法仅在客户端单击元素并将鼠标移动至少 10 像素时才触发拖动开始?
注意:这与滚动无关。
来自https://jqueryui.com/draggable/ 现场演示的代码示例:
<style>#draggable { width: 150px; height: 150px; padding: 0.5em; }</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<script>
$(function(){
$("#draggable").draggable();
//goal is to only starts dragging if mouse moved more than 10px
});
</script>
<div id="draggable" class="ui-widget-content">
<p>Drag me around</p>
</div>
【问题讨论】:
-
有什么代码可以分享吗?
-
我在问题中添加了代码。
标签: javascript jquery jquery-ui jquery-ui-draggable