Skip to content

Commit f152f93

Browse files
committed
chore(dist): 3.0.2 build
1 parent 9124ec1 commit f152f93

File tree

5 files changed

+94
-118
lines changed

5 files changed

+94
-118
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 v3.0.1
2+
* he-tree-vue v3.0.2
33
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)
44
* Homepage: https://he-tree-vue.phphe.com
55
* Released under the MIT License.
@@ -1370,16 +1370,30 @@ function makeTreeDraggable(treeEl) {
13701370
},
13711371
beforeDrop: function () {
13721372
var _beforeDrop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(store, dhOptions) {
1373-
var endEvent, movingEl, placeholder, tempChildren, movedCount, targetTreeEl, startTreeEl, maskTree, maskTree2, pathChanged, isPathChanged;
1373+
var endEvent, movingEl, placeholder, tempChildren, movedCount, targetTreeEl, startTreeEl, maskTree, maskTree2, pathChanged, isPathChanged, isDownwardsSameLevelMove;
13741374
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
13751375
while (1) {
13761376
switch (_context14.prev = _context14.next) {
13771377
case 0:
1378-
isPathChanged = function _isPathChanged() {
1378+
isDownwardsSameLevelMove = function _isDownwardsSameLevel() {
13791379
var startTree = store.startTree,
13801380
targetTree = store.targetTree,
13811381
startPath = store.startPath,
13821382
targetPath = store.targetPath;
1383+
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);
1384+
};
1385+
1386+
isPathChanged = function _isPathChanged() {
1387+
var startTree = store.startTree,
1388+
targetTree = store.targetTree,
1389+
startPath = store.startPath,
1390+
targetPath = store.targetPath,
1391+
isDownwardsSameLevelMove = store.isDownwardsSameLevelMove;
1392+
1393+
if (isDownwardsSameLevelMove) {
1394+
return hp.arrayLast(startPath) < hp.arrayLast(targetPath) - 1; // if equal, not moved
1395+
}
1396+
13831397
return startTree !== targetTree || startPath.toString() !== targetPath.toString();
13841398
};
13851399

@@ -1405,6 +1419,7 @@ function makeTreeDraggable(treeEl) {
14051419

14061420

14071421
store.targetPath = options.getPathByBranchEl(placeholder);
1422+
store.isDownwardsSameLevelMove = isDownwardsSameLevelMove();
14081423
pathChanged = isPathChanged();
14091424
store.targetPathNotEqualToStartPath = pathChanged;
14101425
store.pathChangePrevented = false;
@@ -1426,19 +1441,19 @@ function makeTreeDraggable(treeEl) {
14261441

14271442
store.updateMovedElementStyle(); //
14281443

1429-
_context14.next = 10;
1444+
_context14.next = 11;
14301445
return options.afterDrop(store, dhOptions);
14311446

1432-
case 10:
1447+
case 11:
14331448
if (!maskTree) {
1434-
_context14.next = 16;
1449+
_context14.next = 17;
14351450
break;
14361451
}
14371452

1438-
_context14.next = 13;
1453+
_context14.next = 14;
14391454
return hp.waitTime(30);
14401455

1441-
case 13:
1456+
case 14:
14421457
hp.removeEl(maskTree);
14431458
targetTreeEl.style.display = 'block';
14441459

@@ -1447,7 +1462,7 @@ function makeTreeDraggable(treeEl) {
14471462
startTreeEl.style.display = 'block';
14481463
}
14491464

1450-
case 16:
1465+
case 17:
14511466
case "end":
14521467
return _context14.stop();
14531468
}
@@ -1727,10 +1742,6 @@ var Draggable_vue = {
17271742
index2 = _step3$value.index;
17281743

17291744
if (hp.hasClass(el, 'tree-branch') || hp.hasClass(el, 'tree-placeholder')) {
1730-
if (el === store.dragBranchEl) {
1731-
continue;
1732-
}
1733-
17341745
if (el === branchEl) {
17351746
break;
17361747
}
@@ -1926,40 +1937,21 @@ var Draggable_vue = {
19261937
var startTree = store.startTree,
19271938
targetTree = store.targetTree,
19281939
startPath = store.startPath,
1929-
targetPath = store.targetPath,
19301940
dragNode = store.dragNode;
1941+
var targetPath = store.targetPath;
19311942

19321943
if (_this.cloneWhenDrag !== true) {
19331944
// remove from start position
19341945
var startParentPath = hp.arrayWithoutEnd(startPath, 1);
19351946
var startParent = startTree.getNodeByPath(startParentPath);
19361947
var startSiblings = startParentPath.length === 0 ? startTree.treeData : startParent.children;
19371948
var startIndex = hp.arrayLast(startPath);
1938-
startSiblings.splice(startIndex, 1); // update targetPath
1939-
1940-
if (startTree === targetTree) {
1941-
if (startPath.length <= targetPath.length) {
1942-
var lenNoEnd = startPath.length - 1;
1943-
var same = true;
1944-
1945-
for (var i = 0; i < lenNoEnd; i++) {
1946-
var s = startPath[i];
1947-
var _t = targetPath[i];
1949+
startSiblings.splice(startIndex, 1); // update targetPath if isDownwardsSameLevelMove
19481950

1949-
if (s !== _t) {
1950-
same = false;
1951-
break;
1952-
}
1953-
}
1954-
1955-
if (same) {
1956-
var endIndex = startPath.length - 1;
1957-
1958-
if (startPath[endIndex] < targetPath[endIndex]) {
1959-
targetPath[endIndex] -= 1;
1960-
}
1961-
}
1962-
}
1951+
if (store.isDownwardsSameLevelMove) {
1952+
targetPath = targetPath.slice(0);
1953+
var endIndex = startPath.length - 1;
1954+
targetPath[endIndex] -= 1;
19631955
}
19641956
} // insert to target position
19651957

dist/he-tree-vue.esm.js

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*!
2-
* he-tree-vue v3.0.1
2+
* he-tree-vue v3.0.2
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 { createVNode } from 'vue';
88
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
99
import _defineProperty from '@babel/runtime/helpers/defineProperty';
10-
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';
10+
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';
1111
import { updatablePropsEvenUnbound, hookHelper } from 'vue-functions';
1212
import _regeneratorRuntime from '@babel/runtime/regenerator';
1313
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
@@ -1364,16 +1364,30 @@ function makeTreeDraggable(treeEl) {
13641364
},
13651365
beforeDrop: function () {
13661366
var _beforeDrop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(store, dhOptions) {
1367-
var endEvent, movingEl, placeholder, tempChildren, movedCount, targetTreeEl, startTreeEl, maskTree, maskTree2, pathChanged, isPathChanged;
1367+
var endEvent, movingEl, placeholder, tempChildren, movedCount, targetTreeEl, startTreeEl, maskTree, maskTree2, pathChanged, isPathChanged, isDownwardsSameLevelMove;
13681368
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
13691369
while (1) {
13701370
switch (_context14.prev = _context14.next) {
13711371
case 0:
1372-
isPathChanged = function _isPathChanged() {
1372+
isDownwardsSameLevelMove = function _isDownwardsSameLevel() {
13731373
var startTree = store.startTree,
13741374
targetTree = store.targetTree,
13751375
startPath = store.startPath,
13761376
targetPath = store.targetPath;
1377+
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);
1378+
};
1379+
1380+
isPathChanged = function _isPathChanged() {
1381+
var startTree = store.startTree,
1382+
targetTree = store.targetTree,
1383+
startPath = store.startPath,
1384+
targetPath = store.targetPath,
1385+
isDownwardsSameLevelMove = store.isDownwardsSameLevelMove;
1386+
1387+
if (isDownwardsSameLevelMove) {
1388+
return arrayLast(startPath) < arrayLast(targetPath) - 1; // if equal, not moved
1389+
}
1390+
13771391
return startTree !== targetTree || startPath.toString() !== targetPath.toString();
13781392
};
13791393

@@ -1399,6 +1413,7 @@ function makeTreeDraggable(treeEl) {
13991413

14001414

14011415
store.targetPath = options.getPathByBranchEl(placeholder);
1416+
store.isDownwardsSameLevelMove = isDownwardsSameLevelMove();
14021417
pathChanged = isPathChanged();
14031418
store.targetPathNotEqualToStartPath = pathChanged;
14041419
store.pathChangePrevented = false;
@@ -1420,19 +1435,19 @@ function makeTreeDraggable(treeEl) {
14201435

14211436
store.updateMovedElementStyle(); //
14221437

1423-
_context14.next = 10;
1438+
_context14.next = 11;
14241439
return options.afterDrop(store, dhOptions);
14251440

1426-
case 10:
1441+
case 11:
14271442
if (!maskTree) {
1428-
_context14.next = 16;
1443+
_context14.next = 17;
14291444
break;
14301445
}
14311446

1432-
_context14.next = 13;
1447+
_context14.next = 14;
14331448
return waitTime(30);
14341449

1435-
case 13:
1450+
case 14:
14361451
removeEl(maskTree);
14371452
targetTreeEl.style.display = 'block';
14381453

@@ -1441,7 +1456,7 @@ function makeTreeDraggable(treeEl) {
14411456
startTreeEl.style.display = 'block';
14421457
}
14431458

1444-
case 16:
1459+
case 17:
14451460
case "end":
14461461
return _context14.stop();
14471462
}
@@ -1721,10 +1736,6 @@ var Draggable_vue = {
17211736
index2 = _step3$value.index;
17221737

17231738
if (hasClass(el, 'tree-branch') || hasClass(el, 'tree-placeholder')) {
1724-
if (el === store.dragBranchEl) {
1725-
continue;
1726-
}
1727-
17281739
if (el === branchEl) {
17291740
break;
17301741
}
@@ -1920,40 +1931,21 @@ var Draggable_vue = {
19201931
var startTree = store.startTree,
19211932
targetTree = store.targetTree,
19221933
startPath = store.startPath,
1923-
targetPath = store.targetPath,
19241934
dragNode = store.dragNode;
1935+
var targetPath = store.targetPath;
19251936

19261937
if (_this.cloneWhenDrag !== true) {
19271938
// remove from start position
19281939
var startParentPath = arrayWithoutEnd(startPath, 1);
19291940
var startParent = startTree.getNodeByPath(startParentPath);
19301941
var startSiblings = startParentPath.length === 0 ? startTree.treeData : startParent.children;
19311942
var startIndex = arrayLast(startPath);
1932-
startSiblings.splice(startIndex, 1); // update targetPath
1933-
1934-
if (startTree === targetTree) {
1935-
if (startPath.length <= targetPath.length) {
1936-
var lenNoEnd = startPath.length - 1;
1937-
var same = true;
1938-
1939-
for (var i = 0; i < lenNoEnd; i++) {
1940-
var s = startPath[i];
1941-
var _t = targetPath[i];
1943+
startSiblings.splice(startIndex, 1); // update targetPath if isDownwardsSameLevelMove
19421944

1943-
if (s !== _t) {
1944-
same = false;
1945-
break;
1946-
}
1947-
}
1948-
1949-
if (same) {
1950-
var endIndex = startPath.length - 1;
1951-
1952-
if (startPath[endIndex] < targetPath[endIndex]) {
1953-
targetPath[endIndex] -= 1;
1954-
}
1955-
}
1956-
}
1945+
if (store.isDownwardsSameLevelMove) {
1946+
targetPath = targetPath.slice(0);
1947+
var endIndex = startPath.length - 1;
1948+
targetPath[endIndex] -= 1;
19571949
}
19581950
} // insert to target position
19591951

0 commit comments

Comments
 (0)