提交 44662729 编写于 作者: S sp-kilobug

"distance" option

An attempt to implement the "distance" option (like http://api.jqueryui.com/sortable/#option-distance).
This is useful when your sortable element is also clickable. This prevents the drag to begin due to a micro-movement when you click.
上级 1065b924
......@@ -323,6 +323,9 @@
nextEl = dragEl.nextSibling;
activeGroup = options.group;
this._lastX = evt.clientX;
this._lastY = evt.clientY;
dragStartFn = function () {
// Delayed drag has been triggered
// we can re-enable the events: touchmove/mousemove
......@@ -463,6 +466,15 @@
_onTouchMove: function (/**TouchEvent*/evt) {
if (this.options.distance && this.options.distance > 0) {
// sorting will not start until mouse is dragged at a minimum distance
// this is used to prevent unwanted move during a simple click on a sortable element
if (!Sortable.active && !(Math.abs(evt.clientX - this._lastX) > this.options.distance || Math.abs(evt.clientY - this._lastY) > this.options.distance)) {
return;
}
}
if (tapEvt) {
// only set the status to dragging, when we are actually dragging
if (!Sortable.active) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册