Skip to content

Commit 5efffd7

Browse files
committed
chore(dist): build
1 parent cb64dac commit 5efffd7

File tree

6 files changed

+96
-137
lines changed

6 files changed

+96
-137
lines changed

dist/he-tree-vue.cjs.js

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* he-tree-vue v2.0.8
2+
* he-tree-vue v2.0.9
33
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)
44
* Homepage: https://he-tree-vue.phphe.com
55
* Released under the MIT License.
@@ -1399,16 +1399,30 @@ function makeTreeDraggable(treeEl) {
13991399
},
14001400
beforeDrop: function () {
14011401
var _beforeDrop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(store, dhOptions) {
1402-
var endEvent, movingEl, placeholder, tempChildren, movedCount, targetTreeEl, startTreeEl, maskTree, maskTree2, pathChanged, isPathChanged;
1402+
var endEvent, movingEl, placeholder, tempChildren, movedCount, targetTreeEl, startTreeEl, maskTree, maskTree2, pathChanged, isPathChanged, isDownwardsSameLevelMove;
14031403
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
14041404
while (1) {
14051405
switch (_context14.prev = _context14.next) {
14061406
case 0:
1407-
isPathChanged = function _isPathChanged() {
1407+
isDownwardsSameLevelMove = function _isDownwardsSameLevel() {
14081408
var startTree = store.startTree,
14091409
targetTree = store.targetTree,
14101410
startPath = store.startPath,
14111411
targetPath = store.targetPath;
1412+
return startTree === targetTree && startPath.length === targetPath.length && startPath.slice(0, startPath.length - 1).toString() === targetPath.slice(0, targetPath.length - 1).toString() && hp.arrayLast(startPath) < hp.arrayLast(targetPath);
1413+
};
1414+
1415+
isPathChanged = function _isPathChanged() {
1416+
var startTree = store.startTree,
1417+
targetTree = store.targetTree,
1418+
startPath = store.startPath,
1419+
targetPath = store.targetPath,
1420+
isDownwardsSameLevelMove = store.isDownwardsSameLevelMove;
1421+
1422+
if (isDownwardsSameLevelMove) {
1423+
return hp.arrayLast(startPath) < hp.arrayLast(targetPath) - 1; // if equal, not moved
1424+
}
1425+
14121426
return startTree !== targetTree || startPath.toString() !== targetPath.toString();
14131427
};
14141428

@@ -1434,6 +1448,7 @@ function makeTreeDraggable(treeEl) {
14341448

14351449

14361450
store.targetPath = options.getPathByBranchEl(placeholder);
1451+
store.isDownwardsSameLevelMove = isDownwardsSameLevelMove();
14371452
pathChanged = isPathChanged();
14381453
store.targetPathNotEqualToStartPath = pathChanged;
14391454
store.pathChangePrevented = false;
@@ -1455,19 +1470,19 @@ function makeTreeDraggable(treeEl) {
14551470

14561471
store.updateMovedElementStyle(); //
14571472

1458-
_context14.next = 10;
1473+
_context14.next = 11;
14591474
return options.afterDrop(store, dhOptions);
14601475

1461-
case 10:
1476+
case 11:
14621477
if (!maskTree) {
1463-
_context14.next = 16;
1478+
_context14.next = 17;
14641479
break;
14651480
}
14661481

1467-
_context14.next = 13;
1482+
_context14.next = 14;
14681483
return hp.waitTime(0);
14691484

1470-
case 13:
1485+
case 14:
14711486
hp.removeEl(maskTree);
14721487
targetTreeEl.style.display = 'block';
14731488

@@ -1476,7 +1491,7 @@ function makeTreeDraggable(treeEl) {
14761491
startTreeEl.style.display = 'block';
14771492
}
14781493

1479-
case 16:
1494+
case 17:
14801495
case "end":
14811496
return _context14.stop();
14821497
}
@@ -1755,10 +1770,6 @@ var script = {
17551770
index2 = _step3$value.index;
17561771

17571772
if (hp.hasClass(el, 'tree-branch') || hp.hasClass(el, 'tree-placeholder')) {
1758-
if (el === store.dragBranchEl) {
1759-
continue;
1760-
}
1761-
17621773
if (el === branchEl) {
17631774
break;
17641775
}
@@ -1954,40 +1965,21 @@ var script = {
19541965
var startTree = store.startTree,
19551966
targetTree = store.targetTree,
19561967
startPath = store.startPath,
1957-
targetPath = store.targetPath,
19581968
dragNode = store.dragNode;
1969+
var targetPath = store.targetPath;
19591970

19601971
if (_this.cloneWhenDrag !== true) {
19611972
// remove from start position
19621973
var startParentPath = hp.arrayWithoutEnd(startPath, 1);
19631974
var startParent = startTree.getNodeByPath(startParentPath);
19641975
var startSiblings = startParentPath.length === 0 ? startTree.treeData : startParent.children;
19651976
var startIndex = hp.arrayLast(startPath);
1966-
startSiblings.splice(startIndex, 1); // update targetPath
1967-
1968-
if (startTree === targetTree) {
1969-
if (startPath.length <= targetPath.length) {
1970-
var lenNoEnd = startPath.length - 1;
1971-
var same = true;
1972-
1973-
for (var i = 0; i < lenNoEnd; i++) {
1974-
var s = startPath[i];
1975-
var _t = targetPath[i];
1977+
startSiblings.splice(startIndex, 1); // update targetPath if isDownwardsSameLevelMove
19761978

1977-
if (s !== _t) {
1978-
same = false;
1979-
break;
1980-
}
1981-
}
1982-
1983-
if (same) {
1984-
var endIndex = startPath.length - 1;
1985-
1986-
if (startPath[endIndex] < targetPath[endIndex]) {
1987-
targetPath[endIndex] -= 1;
1988-
}
1989-
}
1990-
}
1979+
if (store.isDownwardsSameLevelMove) {
1980+
targetPath = targetPath.slice(0);
1981+
var endIndex = startPath.length - 1;
1982+
targetPath[endIndex] -= 1;
19911983
}
19921984
} // insert to target position
19931985

dist/he-tree-vue.css

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -321,23 +321,6 @@
321321

322322

323323

324-
325-
326-
327-
328-
329-
330-
331-
332-
333-
334-
335-
336-
337-
338-
339-
340-
341324

342325

343326

dist/he-tree-vue.esm.js

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*!
2-
* he-tree-vue v2.0.8
2+
* he-tree-vue v2.0.9
33
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)
44
* Homepage: https://he-tree-vue.phphe.com
55
* Released under the MIT License.
66
*/
77
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
88
import _defineProperty from '@babel/runtime/helpers/defineProperty';
9-
import { TreeData, randString, findParent, hasClass, createElementFromHTML, insertAfter, addClass, getOffset, getBoundingClientRect, elementsFromPoint, isDescendantOf, attachCache, removeEl, binarySearch, findNodeList, appendTo, insertBefore, prependTo, waitTime, iterateAll, resolveValueOrGettter, arrayWithoutEnd, arrayLast } from 'helper-js';
9+
import { TreeData, randString, findParent, hasClass, createElementFromHTML, insertAfter, addClass, getOffset, getBoundingClientRect, elementsFromPoint, isDescendantOf, attachCache, removeEl, binarySearch, findNodeList, appendTo, insertBefore, prependTo, waitTime, arrayLast, iterateAll, resolveValueOrGettter, arrayWithoutEnd } from 'helper-js';
1010
import { updatablePropsEvenUnbound, hookHelper } from 'vue-functions';
1111
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.mjs';
1212
import Vue from 'vue';
@@ -1393,16 +1393,30 @@ function makeTreeDraggable(treeEl) {
13931393
},
13941394
beforeDrop: function () {
13951395
var _beforeDrop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(store, dhOptions) {
1396-
var endEvent, movingEl, placeholder, tempChildren, movedCount, targetTreeEl, startTreeEl, maskTree, maskTree2, pathChanged, isPathChanged;
1396+
var endEvent, movingEl, placeholder, tempChildren, movedCount, targetTreeEl, startTreeEl, maskTree, maskTree2, pathChanged, isPathChanged, isDownwardsSameLevelMove;
13971397
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
13981398
while (1) {
13991399
switch (_context14.prev = _context14.next) {
14001400
case 0:
1401-
isPathChanged = function _isPathChanged() {
1401+
isDownwardsSameLevelMove = function _isDownwardsSameLevel() {
14021402
var startTree = store.startTree,
14031403
targetTree = store.targetTree,
14041404
startPath = store.startPath,
14051405
targetPath = store.targetPath;
1406+
return startTree === targetTree && startPath.length === targetPath.length && startPath.slice(0, startPath.length - 1).toString() === targetPath.slice(0, targetPath.length - 1).toString() && arrayLast(startPath) < arrayLast(targetPath);
1407+
};
1408+
1409+
isPathChanged = function _isPathChanged() {
1410+
var startTree = store.startTree,
1411+
targetTree = store.targetTree,
1412+
startPath = store.startPath,
1413+
targetPath = store.targetPath,
1414+
isDownwardsSameLevelMove = store.isDownwardsSameLevelMove;
1415+
1416+
if (isDownwardsSameLevelMove) {
1417+
return arrayLast(startPath) < arrayLast(targetPath) - 1; // if equal, not moved
1418+
}
1419+
14061420
return startTree !== targetTree || startPath.toString() !== targetPath.toString();
14071421
};
14081422

@@ -1428,6 +1442,7 @@ function makeTreeDraggable(treeEl) {
14281442

14291443

14301444
store.targetPath = options.getPathByBranchEl(placeholder);
1445+
store.isDownwardsSameLevelMove = isDownwardsSameLevelMove();
14311446
pathChanged = isPathChanged();
14321447
store.targetPathNotEqualToStartPath = pathChanged;
14331448
store.pathChangePrevented = false;
@@ -1449,19 +1464,19 @@ function makeTreeDraggable(treeEl) {
14491464

14501465
store.updateMovedElementStyle(); //
14511466

1452-
_context14.next = 10;
1467+
_context14.next = 11;
14531468
return options.afterDrop(store, dhOptions);
14541469

1455-
case 10:
1470+
case 11:
14561471
if (!maskTree) {
1457-
_context14.next = 16;
1472+
_context14.next = 17;
14581473
break;
14591474
}
14601475

1461-
_context14.next = 13;
1476+
_context14.next = 14;
14621477
return waitTime(0);
14631478

1464-
case 13:
1479+
case 14:
14651480
removeEl(maskTree);
14661481
targetTreeEl.style.display = 'block';
14671482

@@ -1470,7 +1485,7 @@ function makeTreeDraggable(treeEl) {
14701485
startTreeEl.style.display = 'block';
14711486
}
14721487

1473-
case 16:
1488+
case 17:
14741489
case "end":
14751490
return _context14.stop();
14761491
}
@@ -1749,10 +1764,6 @@ var script = {
17491764
index2 = _step3$value.index;
17501765

17511766
if (hasClass(el, 'tree-branch') || hasClass(el, 'tree-placeholder')) {
1752-
if (el === store.dragBranchEl) {
1753-
continue;
1754-
}
1755-
17561767
if (el === branchEl) {
17571768
break;
17581769
}
@@ -1948,40 +1959,21 @@ var script = {
19481959
var startTree = store.startTree,
19491960
targetTree = store.targetTree,
19501961
startPath = store.startPath,
1951-
targetPath = store.targetPath,
19521962
dragNode = store.dragNode;
1963+
var targetPath = store.targetPath;
19531964

19541965
if (_this.cloneWhenDrag !== true) {
19551966
// remove from start position
19561967
var startParentPath = arrayWithoutEnd(startPath, 1);
19571968
var startParent = startTree.getNodeByPath(startParentPath);
19581969
var startSiblings = startParentPath.length === 0 ? startTree.treeData : startParent.children;
19591970
var startIndex = arrayLast(startPath);
1960-
startSiblings.splice(startIndex, 1); // update targetPath
1961-
1962-
if (startTree === targetTree) {
1963-
if (startPath.length <= targetPath.length) {
1964-
var lenNoEnd = startPath.length - 1;
1965-
var same = true;
1966-
1967-
for (var i = 0; i < lenNoEnd; i++) {
1968-
var s = startPath[i];
1969-
var _t = targetPath[i];
1971+
startSiblings.splice(startIndex, 1); // update targetPath if isDownwardsSameLevelMove
19701972

1971-
if (s !== _t) {
1972-
same = false;
1973-
break;
1974-
}
1975-
}
1976-
1977-
if (same) {
1978-
var endIndex = startPath.length - 1;
1979-
1980-
if (startPath[endIndex] < targetPath[endIndex]) {
1981-
targetPath[endIndex] -= 1;
1982-
}
1983-
}
1984-
}
1973+
if (store.isDownwardsSameLevelMove) {
1974+
targetPath = targetPath.slice(0);
1975+
var endIndex = startPath.length - 1;
1976+
targetPath[endIndex] -= 1;
19851977
}
19861978
} // insert to target position
19871979

0 commit comments

Comments
 (0)