Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c9cff71

Browse files
committed
chore(dist): build
1 parent 337a09b commit c9cff71

File tree

6 files changed

+173
-90
lines changed

6 files changed

+173
-90
lines changed

‎dist/he-tree-vue.cjs.js‎

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* he-tree-vue v2.0.9
2+
* he-tree-vue v2.0.10
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,31 +1399,33 @@ 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,isDownwardsSameLevelMove;
1402+
var endEvent, movingEl, placeholder, tempChildren, movedCount, targetTreeEl, startTreeEl, maskTree, maskTree2, pathChanged, isPathChanged;
14031403
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
14041404
while (1) {
14051405
switch (_context14.prev = _context14.next) {
14061406
case 0:
1407-
isDownwardsSameLevelMove = function _isDownwardsSameLevel() {
1408-
var startTree = store.startTree,
1409-
targetTree = store.targetTree,
1410-
startPath = store.startPath,
1411-
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-
14151407
isPathChanged = function _isPathChanged() {
14161408
var startTree = store.startTree,
14171409
targetTree = store.targetTree,
14181410
startPath = store.startPath,
1419-
targetPath = store.targetPath,
1420-
isDownwardsSameLevelMove = store.isDownwardsSameLevelMove;
1411+
targetPath = store.targetPath;
14211412

1422-
if (isDownwardsSameLevelMove) {
1423-
return hp.arrayLast(startPath) < hp.arrayLast(targetPath) - 1; // if equal, not moved
1413+
if (startTree === targetTree && startPath.length === targetPath.length) {
1414+
if (startPath.toString() === targetPath.toString()) {
1415+
return false;
1416+
} else {
1417+
// downward same-level move, the end of targetPath is 1 more than real value
1418+
// 同级向下移动时, targetPath的末位比真实值大1
1419+
var t = startPath.slice(0);
1420+
t[t.length - 1]++;
1421+
1422+
if (t.toString() === targetPath.toString()) {
1423+
return false;
1424+
}
1425+
}
14241426
}
14251427

1426-
return startTree!==targetTree||startPath.toString()!==targetPath.toString();
1428+
return true;
14271429
};
14281430

14291431
endEvent = store.endEvent;
@@ -1448,7 +1450,6 @@ function makeTreeDraggable(treeEl) {
14481450

14491451

14501452
store.targetPath = options.getPathByBranchEl(placeholder);
1451-
store.isDownwardsSameLevelMove = isDownwardsSameLevelMove();
14521453
pathChanged = isPathChanged();
14531454
store.targetPathNotEqualToStartPath = pathChanged;
14541455
store.pathChangePrevented = false;
@@ -1470,19 +1471,19 @@ function makeTreeDraggable(treeEl) {
14701471

14711472
store.updateMovedElementStyle(); //
14721473

1473-
_context14.next = 11;
1474+
_context14.next = 10;
14741475
return options.afterDrop(store, dhOptions);
14751476

1476-
case 11:
1477+
case 10:
14771478
if (!maskTree) {
1478-
_context14.next = 17;
1479+
_context14.next = 16;
14791480
break;
14801481
}
14811482

1482-
_context14.next = 14;
1483+
_context14.next = 13;
14831484
return hp.waitTime(0);
14841485

1485-
case 14:
1486+
case 13:
14861487
hp.removeEl(maskTree);
14871488
targetTreeEl.style.display = 'block';
14881489

@@ -1491,7 +1492,7 @@ function makeTreeDraggable(treeEl) {
14911492
startTreeEl.style.display = 'block';
14921493
}
14931494

1494-
case 17:
1495+
case 16:
14951496
case "end":
14961497
return _context14.stop();
14971498
}
@@ -1974,12 +1975,33 @@ var script = {
19741975
var startParent = startTree.getNodeByPath(startParentPath);
19751976
var startSiblings = startParentPath.length === 0 ? startTree.treeData : startParent.children;
19761977
var startIndex = hp.arrayLast(startPath);
1977-
startSiblings.splice(startIndex, 1); // update targetPath if isDownwardsSameLevelMove
1978-
1979-
if (store.isDownwardsSameLevelMove) {
1980-
targetPath = targetPath.slice(0);
1981-
var endIndex = startPath.length - 1;
1982-
targetPath[endIndex] -= 1;
1978+
startSiblings.splice(startIndex, 1); // remove node from the starting position may affect the target path.
1979+
// example
1980+
// startPath targetPath
1981+
// [0] [1]
1982+
// [0] [1, 0]
1983+
// [3, 1] [3, 3]
1984+
// [3, 1] [3, 3, 5]
1985+
// above targetPaths should be transformed to [0], [0, 0] [3, 2] [3, 2, 5]
1986+
1987+
if (startTree === targetTree) {
1988+
if (startPath.length <= targetPath.length) {
1989+
var sw = startPath.slice(0, startPath.length - 1); // without end
1990+
1991+
var tw = targetPath.slice(0, sw.length); // same length with sw
1992+
1993+
if (sw.toString() === tw.toString()) {
1994+
var endIndex = sw.length;
1995+
1996+
if (startPath[endIndex] < targetPath[endIndex]) {
1997+
targetPath = targetPath.slice(0); // create a copy of targetPath
1998+
1999+
targetPath[endIndex] -= 1;
2000+
} else if (startPath[endIndex] === targetPath[endIndex]) {
2001+
console.error('Draggable.afterDrop: That is impossible!');
2002+
}
2003+
}
2004+
}
19832005
}
19842006
} // insert to target position
19852007

‎dist/he-tree-vue.css‎

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

322322

323323

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

325342

326343

‎dist/he-tree-vue.esm.js‎

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*!
2-
* he-tree-vue v2.0.9
2+
* he-tree-vue v2.0.10
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, arrayLast,iterateAll, resolveValueOrGettter, arrayWithoutEnd } from 'helper-js';
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';
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,31 +1393,33 @@ 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,isDownwardsSameLevelMove;
1396+
var endEvent, movingEl, placeholder, tempChildren, movedCount, targetTreeEl, startTreeEl, maskTree, maskTree2, pathChanged, isPathChanged;
13971397
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
13981398
while (1) {
13991399
switch (_context14.prev = _context14.next) {
14001400
case 0:
1401-
isDownwardsSameLevelMove = function _isDownwardsSameLevel() {
1402-
var startTree = store.startTree,
1403-
targetTree = store.targetTree,
1404-
startPath = store.startPath,
1405-
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-
14091401
isPathChanged = function _isPathChanged() {
14101402
var startTree = store.startTree,
14111403
targetTree = store.targetTree,
14121404
startPath = store.startPath,
1413-
targetPath = store.targetPath,
1414-
isDownwardsSameLevelMove = store.isDownwardsSameLevelMove;
1405+
targetPath = store.targetPath;
14151406

1416-
if (isDownwardsSameLevelMove) {
1417-
return arrayLast(startPath) < arrayLast(targetPath) - 1; // if equal, not moved
1407+
if (startTree === targetTree && startPath.length === targetPath.length) {
1408+
if (startPath.toString() === targetPath.toString()) {
1409+
return false;
1410+
} else {
1411+
// downward same-level move, the end of targetPath is 1 more than real value
1412+
// 同级向下移动时, targetPath的末位比真实值大1
1413+
var t = startPath.slice(0);
1414+
t[t.length - 1]++;
1415+
1416+
if (t.toString() === targetPath.toString()) {
1417+
return false;
1418+
}
1419+
}
14181420
}
14191421

1420-
return startTree!==targetTree||startPath.toString()!==targetPath.toString();
1422+
return true;
14211423
};
14221424

14231425
endEvent = store.endEvent;
@@ -1442,7 +1444,6 @@ function makeTreeDraggable(treeEl) {
14421444

14431445

14441446
store.targetPath = options.getPathByBranchEl(placeholder);
1445-
store.isDownwardsSameLevelMove = isDownwardsSameLevelMove();
14461447
pathChanged = isPathChanged();
14471448
store.targetPathNotEqualToStartPath = pathChanged;
14481449
store.pathChangePrevented = false;
@@ -1464,19 +1465,19 @@ function makeTreeDraggable(treeEl) {
14641465

14651466
store.updateMovedElementStyle(); //
14661467

1467-
_context14.next = 11;
1468+
_context14.next = 10;
14681469
return options.afterDrop(store, dhOptions);
14691470

1470-
case 11:
1471+
case 10:
14711472
if (!maskTree) {
1472-
_context14.next = 17;
1473+
_context14.next = 16;
14731474
break;
14741475
}
14751476

1476-
_context14.next = 14;
1477+
_context14.next = 13;
14771478
return waitTime(0);
14781479

1479-
case 14:
1480+
case 13:
14801481
removeEl(maskTree);
14811482
targetTreeEl.style.display = 'block';
14821483

@@ -1485,7 +1486,7 @@ function makeTreeDraggable(treeEl) {
14851486
startTreeEl.style.display = 'block';
14861487
}
14871488

1488-
case 17:
1489+
case 16:
14891490
case "end":
14901491
return _context14.stop();
14911492
}
@@ -1968,12 +1969,33 @@ var script = {
19681969
var startParent = startTree.getNodeByPath(startParentPath);
19691970
var startSiblings = startParentPath.length === 0 ? startTree.treeData : startParent.children;
19701971
var startIndex = arrayLast(startPath);
1971-
startSiblings.splice(startIndex, 1); // update targetPath if isDownwardsSameLevelMove
1972-
1973-
if (store.isDownwardsSameLevelMove) {
1974-
targetPath = targetPath.slice(0);
1975-
var endIndex = startPath.length - 1;
1976-
targetPath[endIndex] -= 1;
1972+
startSiblings.splice(startIndex, 1); // remove node from the starting position may affect the target path.
1973+
// example
1974+
// startPath targetPath
1975+
// [0] [1]
1976+
// [0] [1, 0]
1977+
// [3, 1] [3, 3]
1978+
// [3, 1] [3, 3, 5]
1979+
// above targetPaths should be transformed to [0], [0, 0] [3, 2] [3, 2, 5]
1980+
1981+
if (startTree === targetTree) {
1982+
if (startPath.length <= targetPath.length) {
1983+
var sw = startPath.slice(0, startPath.length - 1); // without end
1984+
1985+
var tw = targetPath.slice(0, sw.length); // same length with sw
1986+
1987+
if (sw.toString() === tw.toString()) {
1988+
var endIndex = sw.length;
1989+
1990+
if (startPath[endIndex] < targetPath[endIndex]) {
1991+
targetPath = targetPath.slice(0); // create a copy of targetPath
1992+
1993+
targetPath[endIndex] -= 1;
1994+
} else if (startPath[endIndex] === targetPath[endIndex]) {
1995+
console.error('Draggable.afterDrop: That is impossible!');
1996+
}
1997+
}
1998+
}
19771999
}
19782000
} // insert to target position
19792001

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /