Skip to content

Commit 66e7fd4

Browse files
committed
fix: optimize animation effects
1 parent f550a9d commit 66e7fd4

File tree

4 files changed

+45
-45
lines changed

4 files changed

+45
-45
lines changed

dist/virtual-drag-list.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-virtual-drag-list v2.9.3
2+
* vue-virtual-drag-list v2.9.4
33
* open source under the MIT license
44
* https://github.com/mfuu/vue-virtual-drag-list#readme
55
*/
@@ -260,7 +260,7 @@
260260
var sortableDnd_min = {exports: {}};
261261

262262
/*!
263-
* sortable-dnd v0.6.19
263+
* sortable-dnd v0.6.20
264264
* open source under the MIT license
265265
* https://github.com/mfuu/sortable-dnd#readme
266266
*/
@@ -448,7 +448,7 @@
448448
function N(t) {
449449
this.options = t, this.stack = [];
450450
}
451-
function P(t) {
451+
function O(t) {
452452
this.options = t || {}, this.selects = [];
453453
}
454454
window.requestAnimationFrame || (window.requestAnimationFrame = function (t) {
@@ -534,7 +534,7 @@
534534
}, s);
535535
}
536536
}
537-
}, P.prototype = {
537+
}, O.prototype = {
538538
active: function () {
539539
return !!D;
540540
},
@@ -631,9 +631,9 @@
631631
}
632632
}
633633
};
634-
var A,
634+
var P,
635+
A,
635636
H,
636-
O,
637637
k,
638638
L,
639639
X,
@@ -700,13 +700,14 @@
700700
selectedClass: "",
701701
placeholderClass: "",
702702
swapOnDrop: !0,
703+
removeCloneOnDrop: !0,
703704
fallbackOnBody: !1,
704705
supportTouch: "ontouchstart" in window,
705706
emptyInsertThreshold: -1
706707
};
707708
for (var i in o) !(i in this.options) && (this.options[i] = o[i]);
708709
for (var r in et(n), this) "_" === r.charAt(0) && "function" == typeof this[r] && (this[r] = this[r].bind(this));
709-
c(t, this.options.supportTouch ? "touchstart" : "mousedown", this._onDrag), this.autoScroller = new M(this.options), this.multiplayer = new P(this.options), this.animator = new N(this.options), tt.push(t);
710+
c(t, this.options.supportTouch ? "touchstart" : "mousedown", this._onDrag), this.autoScroller = new M(this.options), this.multiplayer = new O(this.options), this.animator = new N(this.options), tt.push(t);
710711
}
711712
return ot.prototype = {
712713
constructor: ot,
@@ -745,12 +746,12 @@
745746
_onStart: function (t, e) {
746747
x(e);
747748
var n = g(k);
748-
A = this.el, H = this.el, F = k, z = n, G = n, V = n, J = {
749+
P = this.el, A = this.el, F = k, z = n, G = n, V = n, J = {
749750
to: this.el,
750751
target: k,
751752
newIndex: n,
752753
relative: 0
753-
}, K = k, O = this.el, Y = k.cloneNode(!0), R = k.parentNode, W = this.options.group.pull, ot.clone = Y, ot.active = this, ot.dragged = k, this.multiplayer.onChoose(), w(k, this.options.chosenClass, !0), C({
754+
}, K = k, H = this.el, Y = k.cloneNode(!0), R = k.parentNode, W = this.options.group.pull, ot.clone = Y, ot.active = this, ot.dragged = k, this.multiplayer.onChoose(), w(k, this.options.chosenClass, !0), C({
754755
sortable: this,
755756
name: "onChoose",
756757
params: this._getParams(e)
@@ -853,12 +854,12 @@
853854
}
854855
},
855856
_allowPut: function () {
856-
if (O === this.el) return !0;
857+
if (H === this.el) return !0;
857858
if (!this.options.group.put) return !1;
858859
var t = this.options.group,
859860
e = t.name,
860861
n = t.put,
861-
o = O[T].options.group;
862+
o = H[T].options.group;
862863
return n.join && n.indexOf(o.name) > -1 || o.name && e && o.name === e;
863864
},
864865
_getDirection: function () {
@@ -891,23 +892,23 @@
891892
params: this._getParams(t, {
892893
target: L
893894
})
894-
}), this.options.sortable || this.el !== O) return this.el === H || e !== this.el && f(this.el) ? void (L && !L.animated && !m(L, Y) && this._allowSwap() && (L !== Y && X !== Y ? (this.el !== H ? this._onInsert(t) : L !== k && this._onChange(t), U = L) : U = L)) : (L = U = null, void this._onInsert(t));
895-
H !== O && (L = U = k, Z = 0, this._onInsert(t));
895+
}), this.options.sortable || this.el !== H) return this.el === A || e !== this.el && f(this.el) ? void (L && !L.animated && !m(L, Y) && this._allowSwap() && (L !== Y && X !== Y ? (this.el !== A ? this._onInsert(t) : L !== k && this._onChange(t), U = L) : U = L)) : (L = U = null, void this._onInsert(t));
896+
A !== H && (L = U = k, Z = 0, this._onInsert(t));
896897
}
897898
},
898899
_onInsert: function (t) {
899900
var e = L || Y,
900-
n = "clone" === W && this.el !== O && H === O,
901-
o = "clone" === W && this.el === O && H !== O,
901+
n = "clone" === W && this.el !== H && A === H,
902+
o = "clone" === W && this.el === H && A !== H,
902903
i = m(L, document),
903904
r = L === k && !i,
904-
s = H[T],
905-
a = O[T];
906-
A = this.el, z = g(Y), F = e, R = i ? L.parentNode : this.el, s.animator.collect(Y.parentNode), this.animator.collect(R), n && (J.target = K, J.newIndex = z, J.relative = K === k ? 0 : _(Y, K), S(k, "display", ""), a.multiplayer.toggleVisible(!0), a.options.group.revertDrag || Y.parentNode.insertBefore(k, Y)), o && (z = g(k), S(k, "display", "none"), this.multiplayer.toggleVisible(!1)), S(Y, "display", r ? "none" : ""), L && i ? R.insertBefore(Y, Z < 0 ? L : L.nextSibling) : R.appendChild(Y), G = r ? V : g(Y), n && a.options.group.revertDrag && (J.target = k, J.newIndex = V, J.relative = 0, C({
905+
s = A[T],
906+
a = H[T];
907+
P = this.el, z = g(Y), F = e, R = i ? L.parentNode : this.el, s.animator.collect(Y.parentNode), this.animator.collect(R), n && (J.target = K, J.newIndex = z, J.relative = K === k ? 0 : _(Y, K), S(k, "display", ""), a.multiplayer.toggleVisible(!0), a.options.group.revertDrag || Y.parentNode.insertBefore(k, Y)), o && (z = g(k), S(k, "display", "none"), this.multiplayer.toggleVisible(!1)), S(Y, "display", r ? "none" : ""), L && i ? R.insertBefore(Y, Z < 0 ? L : L.nextSibling) : R.appendChild(Y), G = r ? V : g(Y), n && a.options.group.revertDrag && (J.target = k, J.newIndex = V, J.relative = 0, C({
907908
sortable: a,
908909
name: "onChange",
909910
params: this._getParams(t, {
910-
to: O,
911+
to: H,
911912
target: k,
912913
newIndex: V,
913914
revertDrag: !0
@@ -922,7 +923,7 @@
922923
sortable: this,
923924
name: "onChange",
924925
params: this._getParams(t, {
925-
from: O,
926+
from: H,
926927
backToOrigin: !0
927928
})
928929
})), o || C({
@@ -931,49 +932,51 @@
931932
params: this._getParams(t, {
932933
oldIndex: -1
933934
})
934-
}), s.animator.animate(), this.animator.animate(), H = this.el;
935+
}), s.animator.animate(), this.animator.animate(), A = this.el;
935936
},
936937
_onChange: function (t) {
937-
this.animator.collect(R), z = g(Y), R = L.parentNode, F = L, this.el === O && (K = L), R.insertBefore(Y, X), G = g(Y), C({
938+
this.animator.collect(R), z = g(Y), R = L.parentNode, F = L, this.el === H && (K = L), R.insertBefore(Y, X), G = g(Y), C({
938939
sortable: this,
939940
name: "onChange",
940941
params: this._getParams(t)
941-
}), this.animator.animate(), H = this.el;
942+
}), this.animator.animate(), A = this.el;
942943
},
943944
_onDrop: function (t) {
944-
this._cancelStart(), h(Q, "touchmove", this._nearestSortable), h(Q, "mousemove", this._nearestSortable), h(Q, "mouseup", this._onDrop), h(Q, "touchend", this._onDrop), h(Q, "touchcancel", this._onDrop), O && (H = O, z = V, F === Y && (F = k), this.animator.collect(R), this.multiplayer.toggleChosenClass(!1), w(k, this.options.chosenClass, !1), C({
945+
this._cancelStart(), h(Q, "touchmove", this._nearestSortable), h(Q, "mousemove", this._nearestSortable), h(Q, "mouseup", this._onDrop), h(Q, "touchend", this._onDrop), h(Q, "touchcancel", this._onDrop), H && (A = H, z = V, F === Y && (F = k), this.animator.collect(R), this.multiplayer.toggleChosenClass(!1), w(k, this.options.chosenClass, !1), C({
945946
sortable: this,
946947
name: "onUnchoose",
947948
params: this._getParams(t)
948-
}), q && this._onEnd(t), !q && this.animator.animate()), !nt(t.changedTouches ? t.changedTouches[0] : t) && this.multiplayer.onSelect(t, k, O, this), B && B.parentNode && B.parentNode.removeChild(B), this.autoScroller.stop(), this.multiplayer.nulling(), this._nulling();
949+
}), q && this._onEnd(t), !q && this.animator.animate()), !nt(t.changedTouches ? t.changedTouches[0] : t) && this.multiplayer.onSelect(t, k, H, this), B && B.parentNode && B.parentNode.removeChild(B), this.autoScroller.stop(), this.multiplayer.nulling(), this._nulling();
949950
},
950951
_onEnd: function (t) {
951952
w(Y, this.options.chosenClass, !1), w(Y, this.options.placeholderClass, !1);
952953
var n = "clone" === W;
953-
this.multiplayer.onDrop(H, A, n);
954+
this.multiplayer.onDrop(A, P, n);
954955
var o = this._getParams(t),
955-
i = this.options.swapOnDrop;
956-
n && H !== A || !("function" == typeof i ? i(o) : i) || R.insertBefore(k, Y), n && H !== A && !this.multiplayer.active() || Y && Y.parentNode && Y.parentNode.removeChild(Y), S(k, "display", ""), this.animator.animate(), H !== A && C({
957-
sortable: H[T],
956+
i = this.options,
957+
r = i.swapOnDrop,
958+
s = i.removeCloneOnDrop;
959+
n && A !== P || !("function" == typeof r ? r(o) : r) || R.insertBefore(k, Y), n && A !== P && !this.multiplayer.active() || !("function" == typeof s ? s(o) : s) || Y && Y.parentNode && Y.parentNode.removeChild(Y), S(k, "display", ""), this.animator.animate(), A !== P && C({
960+
sortable: A[T],
958961
name: "onDrop",
959962
params: e({}, o, n ? J : {
960963
newIndex: -1
961964
})
962965
}), C({
963-
sortable: A[T],
966+
sortable: P[T],
964967
name: "onDrop",
965-
params: e({}, o, H === A ? {} : {
968+
params: e({}, o, A === P ? {} : {
966969
oldIndex: -1
967970
})
968971
});
969972
},
970973
_getParams: function (t) {
971974
var n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {},
972975
o = {};
973-
return o.event = t, o.to = A, o.from = H, o.node = k, o.clone = Y, o.target = F, o.oldIndex = z, o.newIndex = G, o.pullMode = W, e(o, this.multiplayer.params(), n), o.relative = F === k ? 0 : _(Y, F), o;
976+
return o.event = t, o.to = P, o.from = A, o.node = k, o.clone = Y, o.target = F, o.oldIndex = z, o.newIndex = G, o.pullMode = W, e(o, this.multiplayer.params(), n), o.relative = F === k ? 0 : _(Y, F), o;
974977
},
975978
_nulling: function () {
976-
A = H = O = k = L = X = Y = B = F = R = W = z = G = V = j = q = U = J = K = Q = Z = $ = ot.clone = ot.ghost = ot.active = ot.dragged = null;
979+
P = A = H = k = L = X = Y = B = F = R = W = z = G = V = j = q = U = J = K = Q = Z = $ = ot.clone = ot.ghost = ot.active = ot.dragged = null;
977980
},
978981
destroy: function () {
979982
this._cancelStart(), this._nulling(), this.multiplayer.nulling(), this.autoScroller.stop(), h(this.el, "touchstart", this._onDrag), h(this.el, "mousedown", this._onDrag);
@@ -1045,9 +1048,8 @@
10451048
}, {});
10461049
this.sortable = new Dnd(this.el, Object.assign(Object.assign({}, props), {
10471050
emptyInsertThreshold: 0,
1048-
swapOnDrop: function swapOnDrop(event) {
1049-
return event.from === event.to;
1050-
},
1051+
swapOnDrop: false,
1052+
removeCloneOnDrop: false,
10511053
onDrag: function onDrag(event) {
10521054
return _this.onDrag(event);
10531055
},
@@ -1117,9 +1119,7 @@
11171119
if (event.from === this.el && this.reRendered) {
11181120
(_b = Dnd.dragged) === null || _b === void 0 ? void 0 : _b.remove();
11191121
}
1120-
if (event.from !== event.to && event.pullMode === 'clone') {
1121-
(_c = Dnd.clone) === null || _c === void 0 ? void 0 : _c.remove();
1122-
}
1122+
(_c = Dnd.clone) === null || _c === void 0 ? void 0 : _c.remove();
11231123
this.reRendered = false;
11241124
}
11251125
}, {

dist/virtual-drag-list.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-virtual-draglist",
3-
"version": "2.9.3",
3+
"version": "2.9.4",
44
"description": "A virtual scrolling list component that can be sorted by dragging",
55
"main": "dist/virtual-drag-list.min.js",
66
"files": [
@@ -38,7 +38,7 @@
3838
},
3939
"homepage": "https://github.com/mfuu/vue-virtual-drag-list#readme",
4040
"dependencies": {
41-
"sortable-dnd": "latest"
41+
"sortable-dnd": "^0.6.20"
4242
},
4343
"devDependencies": {
4444
"@babel/core": "^7.8.7",

src/core

Submodule core updated 1 file

0 commit comments

Comments
 (0)