uikit 3.11.2-dev.9433cd5fd → 3.11.2-dev.a87448e52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +4 -49
- package/.prettierignore +14 -0
- package/.prettierrc.json +13 -0
- package/.webstorm.js +3 -3
- package/CHANGELOG.md +37 -28
- package/build/.eslintrc.json +1 -3
- package/build/build.js +26 -28
- package/build/icons.js +7 -11
- package/build/less.js +48 -36
- package/build/package.json +2 -2
- package/build/prefix.js +21 -18
- package/build/publishDev.js +6 -8
- package/build/release.js +20 -17
- package/build/scope.js +21 -11
- package/build/scss.js +72 -39
- package/build/util.js +71 -62
- package/build/wrapper/icons.js +0 -2
- package/dist/css/uikit-core-rtl.css +118 -201
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +118 -201
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +120 -207
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +120 -207
- package/dist/css/uikit.min.css +1 -1
- package/dist/js/components/countdown.js +88 -133
- package/dist/js/components/countdown.min.js +1 -1
- package/dist/js/components/filter.js +408 -439
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +1098 -1316
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +1144 -1393
- package/dist/js/components/lightbox.min.js +1 -1
- package/dist/js/components/notification.js +94 -114
- package/dist/js/components/notification.min.js +1 -1
- package/dist/js/components/parallax.js +345 -358
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +343 -357
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +768 -843
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +343 -357
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +645 -793
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +587 -620
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +324 -356
- package/dist/js/components/tooltip.min.js +1 -1
- package/dist/js/components/upload.js +155 -167
- package/dist/js/components/upload.min.js +1 -1
- package/dist/js/uikit-core.js +5412 -6733
- package/dist/js/uikit-core.min.js +1 -1
- package/dist/js/uikit-icons.js +7 -9
- package/dist/js/uikit-icons.min.js +1 -1
- package/dist/js/uikit.js +8008 -9705
- package/dist/js/uikit.min.js +1 -1
- package/jsconfig.json +1 -1
- package/package.json +64 -60
- package/src/js/api/boot.js +25 -32
- package/src/js/api/component.js +15 -28
- package/src/js/api/global.js +6 -12
- package/src/js/api/hooks.js +14 -33
- package/src/js/api/instance.js +7 -15
- package/src/js/api/state.js +79 -100
- package/src/js/components/countdown.js +24 -50
- package/src/js/components/filter.js +70 -66
- package/src/js/components/index.js +13 -13
- package/src/js/components/internal/lightbox-animations.js +14 -25
- package/src/js/components/internal/slider-preload.js +37 -0
- package/src/js/components/internal/slider-transitioner.js +66 -45
- package/src/js/components/internal/slideshow-animations.js +46 -64
- package/src/js/components/lightbox-panel.js +107 -105
- package/src/js/components/lightbox.js +17 -39
- package/src/js/components/notification.js +49 -43
- package/src/js/components/parallax.js +16 -30
- package/src/js/components/slider-parallax.js +13 -23
- package/src/js/components/slider.js +95 -64
- package/src/js/components/slideshow-parallax.js +1 -1
- package/src/js/components/slideshow.js +15 -13
- package/src/js/components/sortable.js +125 -106
- package/src/js/components/tooltip.js +41 -31
- package/src/js/components/upload.js +52 -63
- package/src/js/core/accordion.js +53 -48
- package/src/js/core/alert.js +9 -17
- package/src/js/core/core.js +74 -53
- package/src/js/core/cover.js +11 -15
- package/src/js/core/drop.js +106 -92
- package/src/js/core/form-custom.js +20 -25
- package/src/js/core/gif.js +3 -7
- package/src/js/core/grid.js +57 -58
- package/src/js/core/height-match.js +16 -29
- package/src/js/core/height-viewport.js +28 -35
- package/src/js/core/icon.js +47 -52
- package/src/js/core/img.js +96 -77
- package/src/js/core/index.js +39 -39
- package/src/js/core/leader.js +9 -18
- package/src/js/core/margin.js +21 -37
- package/src/js/core/modal.js +49 -36
- package/src/js/core/nav.js +2 -4
- package/src/js/core/navbar.js +112 -88
- package/src/js/core/offcanvas.js +49 -53
- package/src/js/core/overflow-auto.js +13 -17
- package/src/js/core/responsive.js +14 -12
- package/src/js/core/scroll.js +10 -20
- package/src/js/core/scrollspy-nav.js +34 -31
- package/src/js/core/scrollspy.js +37 -54
- package/src/js/core/sticky.js +130 -91
- package/src/js/core/svg.js +68 -83
- package/src/js/core/switcher.js +47 -46
- package/src/js/core/tab.js +7 -10
- package/src/js/core/toggle.js +66 -67
- package/src/js/core/video.js +11 -22
- package/src/js/mixin/animate.js +19 -20
- package/src/js/mixin/class.js +2 -4
- package/src/js/mixin/container.js +7 -11
- package/src/js/mixin/internal/animate-fade.js +73 -30
- package/src/js/mixin/internal/animate-slide.js +58 -41
- package/src/js/mixin/internal/slideshow-animations.js +7 -14
- package/src/js/mixin/internal/slideshow-transitioner.js +10 -17
- package/src/js/mixin/media.js +5 -10
- package/src/js/mixin/modal.js +89 -66
- package/src/js/mixin/parallax.js +149 -106
- package/src/js/mixin/position.js +26 -20
- package/src/js/mixin/slider-autoplay.js +12 -21
- package/src/js/mixin/slider-drag.js +64 -65
- package/src/js/mixin/slider-nav.js +26 -35
- package/src/js/mixin/slider-reactive.js +2 -8
- package/src/js/mixin/slider.js +48 -55
- package/src/js/mixin/slideshow.js +13 -19
- package/src/js/mixin/togglable.js +89 -63
- package/src/js/uikit-core.js +2 -4
- package/src/js/uikit.js +2 -4
- package/src/js/util/ajax.js +20 -39
- package/src/js/util/animation.js +77 -75
- package/src/js/util/attr.js +17 -21
- package/src/js/util/class.js +14 -52
- package/src/js/util/dimensions.js +56 -43
- package/src/js/util/dom.js +44 -80
- package/src/js/util/env.js +7 -12
- package/src/js/util/event.js +60 -59
- package/src/js/util/fastdom.js +1 -6
- package/src/js/util/filter.js +17 -34
- package/src/js/util/index.js +0 -1
- package/src/js/util/lang.js +82 -121
- package/src/js/util/mouse.js +19 -17
- package/src/js/util/options.js +32 -46
- package/src/js/util/player.js +41 -36
- package/src/js/util/position.js +54 -46
- package/src/js/util/selector.js +43 -58
- package/src/js/util/style.js +39 -49
- package/src/js/util/viewport.js +75 -64
- package/src/less/components/base.less +10 -33
- package/src/less/components/flex.less +0 -9
- package/src/less/components/form-range.less +48 -95
- package/src/less/components/form.less +0 -1
- package/src/less/components/leader.less +0 -1
- package/src/less/components/lightbox.less +0 -1
- package/src/less/components/modal.less +3 -7
- package/src/less/components/navbar.less +0 -7
- package/src/less/components/progress.less +14 -36
- package/src/less/components/slider.less +0 -3
- package/src/less/components/slideshow.less +0 -3
- package/src/less/components/text.less +16 -32
- package/src/less/components/utility.less +22 -0
- package/src/scss/components/base.scss +10 -33
- package/src/scss/components/flex.scss +0 -9
- package/src/scss/components/form-range.scss +48 -95
- package/src/scss/components/form.scss +3 -4
- package/src/scss/components/icon.scss +2 -2
- package/src/scss/components/leader.scss +0 -1
- package/src/scss/components/lightbox.scss +0 -1
- package/src/scss/components/modal.scss +3 -7
- package/src/scss/components/navbar.scss +0 -7
- package/src/scss/components/progress.scss +14 -36
- package/src/scss/components/search.scss +1 -1
- package/src/scss/components/slider.scss +0 -3
- package/src/scss/components/slideshow.scss +0 -3
- package/src/scss/components/text.scss +16 -32
- package/src/scss/components/utility.scss +22 -0
- package/src/scss/mixins-theme.scss +1 -1
- package/src/scss/mixins.scss +1 -1
- package/src/scss/variables-theme.scss +9 -9
- package/src/scss/variables.scss +9 -9
- package/tests/align.html +10 -10
- package/tests/animation.html +2 -2
- package/tests/article.html +2 -2
- package/tests/base.html +3 -3
- package/tests/card.html +10 -10
- package/tests/column.html +3 -3
- package/tests/comment.html +9 -9
- package/tests/dotnav.html +3 -3
- package/tests/image.html +296 -48
- package/tests/images/image-type.avif +0 -0
- package/tests/images/image-type.jpeg +0 -0
- package/tests/images/image-type.webp +0 -0
- package/tests/index.html +8 -8
- package/tests/js/index.js +114 -85
- package/tests/lightbox.html +10 -10
- package/tests/marker.html +2 -2
- package/tests/modal.html +8 -9
- package/tests/navbar.html +2 -2
- package/tests/overlay.html +7 -7
- package/tests/parallax.html +14 -5
- package/tests/position.html +12 -12
- package/tests/slidenav.html +12 -12
- package/tests/slider.html +20 -20
- package/tests/sortable.html +1 -1
- package/tests/sticky-parallax.html +47 -62
- package/tests/svg.html +6 -6
- package/tests/table.html +11 -11
- package/tests/thumbnav.html +12 -12
- package/tests/transition.html +30 -30
- package/tests/utility.html +33 -33
- package/tests/video.html +1 -1
- package/tests/width.html +1 -1
- package/src/js/mixin/flex-bug.js +0 -56
- package/src/js/util/promise.js +0 -191
- package/tests/images/animated.gif +0 -0
- package/tests/images/test.avif +0 -0
- package/tests/images/test.webp +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! UIkit 3.11.2-dev.
|
|
1
|
+
/*! UIkit 3.11.2-dev.a87448e52 | https://www.getuikit.com | (c) 2014 - 2022 YOOtheme | MIT License */
|
|
2
2
|
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('uikit-util')) :
|
|
@@ -7,810 +7,777 @@
|
|
|
7
7
|
})(this, (function (uikitUtil) { 'use strict';
|
|
8
8
|
|
|
9
9
|
function getRows(items) {
|
|
10
|
-
|
|
10
|
+
return sortBy(items, 'top', 'bottom');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function sortBy(items, startProp, endProp) {
|
|
14
|
+
const sorted = [[]];
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var el = items[i];
|
|
20
|
-
|
|
21
|
-
if (!uikitUtil.isVisible(el)) {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var dim = getOffset(el);
|
|
26
|
-
|
|
27
|
-
for (var j = sorted.length - 1; j >= 0; j--) {
|
|
28
|
-
|
|
29
|
-
var current = sorted[j];
|
|
30
|
-
|
|
31
|
-
if (!current[0]) {
|
|
32
|
-
current.push(el);
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var startDim = (void 0);
|
|
37
|
-
if (current[0].offsetParent === el.offsetParent) {
|
|
38
|
-
startDim = getOffset(current[0]);
|
|
39
|
-
} else {
|
|
40
|
-
dim = getOffset(el, true);
|
|
41
|
-
startDim = getOffset(current[0], true);
|
|
42
|
-
}
|
|
16
|
+
for (const el of items) {
|
|
17
|
+
if (!uikitUtil.isVisible(el)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
43
20
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
21
|
+
let dim = getOffset(el);
|
|
22
|
+
|
|
23
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
24
|
+
const current = sorted[i];
|
|
25
|
+
|
|
26
|
+
if (!current[0]) {
|
|
27
|
+
current.push(el);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let startDim;
|
|
32
|
+
if (current[0].offsetParent === el.offsetParent) {
|
|
33
|
+
startDim = getOffset(current[0]);
|
|
34
|
+
} else {
|
|
35
|
+
dim = getOffset(el, true);
|
|
36
|
+
startDim = getOffset(current[0], true);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (dim[startProp] >= startDim[endProp] - 1 && dim[startProp] !== startDim[startProp]) {
|
|
40
|
+
sorted.push([el]);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (dim[endProp] - 1 > startDim[startProp] || dim[startProp] === startDim[startProp]) {
|
|
45
|
+
current.push(el);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (i === 0) {
|
|
50
|
+
sorted.unshift([el]);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
48
55
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
56
|
+
return sorted;
|
|
57
|
+
}
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
59
|
+
function getOffset(element, offset) {if (offset === void 0) {offset = false;}
|
|
60
|
+
let { offsetTop, offsetLeft, offsetHeight, offsetWidth } = element;
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
if (offset) {
|
|
63
|
+
[offsetTop, offsetLeft] = uikitUtil.offsetPosition(element);
|
|
64
|
+
}
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
return {
|
|
67
|
+
top: offsetTop,
|
|
68
|
+
left: offsetLeft,
|
|
69
|
+
bottom: offsetTop + offsetHeight,
|
|
70
|
+
right: offsetLeft + offsetWidth };
|
|
62
71
|
|
|
63
|
-
return sorted;
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
const clsLeave = 'uk-transition-leave';
|
|
75
|
+
const clsEnter = 'uk-transition-enter';
|
|
68
76
|
|
|
69
|
-
|
|
77
|
+
function fade(action, target, duration, stagger) {if (stagger === void 0) {stagger = 0;}
|
|
78
|
+
const index = transitionIndex(target, true);
|
|
79
|
+
const propsIn = { opacity: 1 };
|
|
80
|
+
const propsOut = { opacity: 0 };
|
|
70
81
|
|
|
71
|
-
|
|
72
|
-
var offsetLeft = element.offsetLeft;
|
|
73
|
-
var offsetHeight = element.offsetHeight;
|
|
74
|
-
var offsetWidth = element.offsetWidth;
|
|
82
|
+
const wrapIndexFn = (fn) => () => index === transitionIndex(target) ? fn() : Promise.reject();
|
|
75
83
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
84
|
+
const leaveFn = wrapIndexFn(() => {
|
|
85
|
+
uikitUtil.addClass(target, clsLeave);
|
|
79
86
|
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
return Promise.all(
|
|
88
|
+
getTransitionNodes(target).map(
|
|
89
|
+
(child, i) =>
|
|
90
|
+
new Promise((resolve) =>
|
|
91
|
+
setTimeout(
|
|
92
|
+
() =>
|
|
93
|
+
uikitUtil.Transition.start(child, propsOut, duration / 2, 'ease').then(
|
|
94
|
+
resolve),
|
|
87
95
|
|
|
88
|
-
|
|
89
|
-
var clsEnter = 'uk-transition-enter';
|
|
96
|
+
i * stagger)))).
|
|
90
97
|
|
|
91
|
-
function fade(action, target, duration, stagger) {
|
|
92
|
-
if ( stagger === void 0 ) stagger = 0;
|
|
93
98
|
|
|
94
99
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
var propsOut = {opacity: 0};
|
|
100
|
+
then(() => uikitUtil.removeClass(target, clsLeave));
|
|
101
|
+
});
|
|
98
102
|
|
|
99
|
-
|
|
103
|
+
const enterFn = wrapIndexFn(() => {
|
|
104
|
+
const oldHeight = uikitUtil.height(target);
|
|
100
105
|
|
|
101
|
-
|
|
106
|
+
uikitUtil.addClass(target, clsEnter);
|
|
107
|
+
action();
|
|
102
108
|
|
|
103
|
-
|
|
109
|
+
uikitUtil.css(uikitUtil.children(target), { opacity: 0 });
|
|
104
110
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
// Ensure UIkit updates have propagated
|
|
112
|
+
return new Promise((resolve) =>
|
|
113
|
+
requestAnimationFrame(() => {
|
|
114
|
+
const nodes = uikitUtil.children(target);
|
|
115
|
+
const newHeight = uikitUtil.height(target);
|
|
108
116
|
|
|
109
|
-
|
|
117
|
+
// Ensure Grid cells do not stretch when height is applied
|
|
118
|
+
uikitUtil.css(target, 'alignContent', 'flex-start');
|
|
119
|
+
uikitUtil.height(target, oldHeight);
|
|
110
120
|
|
|
111
|
-
|
|
121
|
+
const transitionNodes = getTransitionNodes(target);
|
|
122
|
+
uikitUtil.css(nodes, propsOut);
|
|
112
123
|
|
|
113
|
-
|
|
124
|
+
const transitions = transitionNodes.map(
|
|
125
|
+
(child, i) =>
|
|
126
|
+
new Promise((resolve) =>
|
|
127
|
+
setTimeout(
|
|
128
|
+
() =>
|
|
129
|
+
uikitUtil.Transition.start(child, propsIn, duration / 2, 'ease').then(
|
|
130
|
+
resolve),
|
|
114
131
|
|
|
115
|
-
|
|
116
|
-
action();
|
|
132
|
+
i * stagger)));
|
|
117
133
|
|
|
118
|
-
uikitUtil.css(uikitUtil.children(target), {opacity: 0});
|
|
119
134
|
|
|
120
|
-
// Ensure UIkit updates have propagated
|
|
121
|
-
return new uikitUtil.Promise(function (resolve) { return requestAnimationFrame(function () {
|
|
122
135
|
|
|
123
|
-
var nodes = uikitUtil.children(target);
|
|
124
|
-
var newHeight = uikitUtil.height(target);
|
|
125
136
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
137
|
+
if (oldHeight !== newHeight) {
|
|
138
|
+
transitions.push(
|
|
139
|
+
uikitUtil.Transition.start(
|
|
140
|
+
target,
|
|
141
|
+
{ height: newHeight },
|
|
142
|
+
duration / 2 + transitionNodes.length * stagger,
|
|
143
|
+
'ease'));
|
|
129
144
|
|
|
130
|
-
var transitionNodes = getTransitionNodes(target);
|
|
131
|
-
uikitUtil.css(nodes, propsOut);
|
|
132
145
|
|
|
133
|
-
|
|
134
|
-
); }
|
|
135
|
-
);
|
|
146
|
+
}
|
|
136
147
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
148
|
+
Promise.all(transitions).then(() => {
|
|
149
|
+
uikitUtil.removeClass(target, clsEnter);
|
|
150
|
+
if (index === transitionIndex(target)) {
|
|
151
|
+
uikitUtil.css(target, { height: '', alignContent: '' });
|
|
152
|
+
uikitUtil.css(nodes, { opacity: '' });
|
|
153
|
+
delete target.dataset.transition;
|
|
154
|
+
}
|
|
155
|
+
resolve();
|
|
156
|
+
});
|
|
157
|
+
}));
|
|
140
158
|
|
|
141
|
-
|
|
142
|
-
uikitUtil.removeClass(target, clsEnter);
|
|
143
|
-
if (index === transitionIndex(target)) {
|
|
144
|
-
uikitUtil.css(target, {height: '', alignContent: ''});
|
|
145
|
-
uikitUtil.css(nodes, {opacity: ''});
|
|
146
|
-
delete target.dataset.transition;
|
|
147
|
-
}
|
|
148
|
-
resolve();
|
|
149
|
-
});
|
|
150
|
-
}); }
|
|
151
|
-
);
|
|
152
|
-
});
|
|
159
|
+
});
|
|
153
160
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
161
|
+
return uikitUtil.hasClass(target, clsLeave) ?
|
|
162
|
+
waitTransitionend(target).then(enterFn) :
|
|
163
|
+
uikitUtil.hasClass(target, clsEnter) ?
|
|
164
|
+
waitTransitionend(target).then(leaveFn).then(enterFn) :
|
|
165
|
+
leaveFn().then(enterFn);
|
|
159
166
|
}
|
|
160
167
|
|
|
161
168
|
function transitionIndex(target, next) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
if (next) {
|
|
170
|
+
target.dataset.transition = 1 + transitionIndex(target);
|
|
171
|
+
}
|
|
165
172
|
|
|
166
|
-
|
|
173
|
+
return uikitUtil.toNumber(target.dataset.transition) || 0;
|
|
167
174
|
}
|
|
168
175
|
|
|
169
176
|
function waitTransitionend(target) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function slide (action, target, duration) {
|
|
177
|
+
return Promise.all(
|
|
178
|
+
uikitUtil.children(target).
|
|
179
|
+
filter(uikitUtil.Transition.inProgress).
|
|
180
|
+
map(
|
|
181
|
+
(el) =>
|
|
182
|
+
new Promise((resolve) => uikitUtil.once(el, 'transitionend transitioncanceled', resolve))));
|
|
179
183
|
|
|
180
|
-
return new uikitUtil.Promise(function (resolve) { return requestAnimationFrame(function () {
|
|
181
184
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// Get current state
|
|
185
|
-
var currentProps = nodes.map(function (el) { return getProps(el, true); });
|
|
186
|
-
var targetProps = uikitUtil.css(target, ['height', 'padding']);
|
|
187
|
-
|
|
188
|
-
// Cancel previous animations
|
|
189
|
-
uikitUtil.Transition.cancel(target);
|
|
190
|
-
nodes.forEach(uikitUtil.Transition.cancel);
|
|
191
|
-
reset(target);
|
|
192
|
-
|
|
193
|
-
// Adding, sorting, removing nodes
|
|
194
|
-
action();
|
|
195
|
-
|
|
196
|
-
// Find new nodes
|
|
197
|
-
nodes = nodes.concat(uikitUtil.children(target).filter(function (el) { return !uikitUtil.includes(nodes, el); }));
|
|
198
|
-
|
|
199
|
-
// Wait for update to propagate
|
|
200
|
-
uikitUtil.Promise.resolve().then(function () {
|
|
201
|
-
|
|
202
|
-
// Force update
|
|
203
|
-
uikitUtil.fastdom.flush();
|
|
185
|
+
}
|
|
204
186
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
187
|
+
function getTransitionNodes(target) {
|
|
188
|
+
return getRows(uikitUtil.children(target)).reduce(
|
|
189
|
+
(nodes, row) =>
|
|
190
|
+
nodes.concat(
|
|
191
|
+
uikitUtil.sortBy(
|
|
192
|
+
row.filter((el) => uikitUtil.isInView(el)),
|
|
193
|
+
'offsetLeft')),
|
|
210
194
|
|
|
211
|
-
// Reset to previous state
|
|
212
|
-
nodes.forEach(function (el, i) { return propsFrom[i] && uikitUtil.css(el, propsFrom[i]); });
|
|
213
|
-
uikitUtil.css(target, uikitUtil.assign({display: 'block'}, targetProps));
|
|
214
195
|
|
|
215
|
-
|
|
216
|
-
requestAnimationFrame(function () {
|
|
196
|
+
[]);
|
|
217
197
|
|
|
218
|
-
|
|
219
|
-
).concat(uikitUtil.Transition.start(target, targetPropsTo, duration, 'ease'));
|
|
198
|
+
}
|
|
220
199
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
200
|
+
function slide (action, target, duration) {
|
|
201
|
+
return new Promise((resolve) =>
|
|
202
|
+
requestAnimationFrame(() => {
|
|
203
|
+
let nodes = uikitUtil.children(target);
|
|
204
|
+
|
|
205
|
+
// Get current state
|
|
206
|
+
const currentProps = nodes.map((el) => getProps(el, true));
|
|
207
|
+
const targetProps = uikitUtil.css(target, ['height', 'padding']);
|
|
208
|
+
|
|
209
|
+
// Cancel previous animations
|
|
210
|
+
uikitUtil.Transition.cancel(target);
|
|
211
|
+
nodes.forEach(uikitUtil.Transition.cancel);
|
|
212
|
+
reset(target);
|
|
213
|
+
|
|
214
|
+
// Adding, sorting, removing nodes
|
|
215
|
+
action();
|
|
216
|
+
|
|
217
|
+
// Find new nodes
|
|
218
|
+
nodes = nodes.concat(uikitUtil.children(target).filter((el) => !uikitUtil.includes(nodes, el)));
|
|
219
|
+
|
|
220
|
+
// Wait for update to propagate
|
|
221
|
+
Promise.resolve().then(() => {
|
|
222
|
+
// Force update
|
|
223
|
+
uikitUtil.fastdom.flush();
|
|
224
|
+
|
|
225
|
+
// Get new state
|
|
226
|
+
const targetPropsTo = uikitUtil.css(target, ['height', 'padding']);
|
|
227
|
+
const [propsTo, propsFrom] = getTransitionProps(target, nodes, currentProps);
|
|
228
|
+
|
|
229
|
+
// Reset to previous state
|
|
230
|
+
nodes.forEach((el, i) => propsFrom[i] && uikitUtil.css(el, propsFrom[i]));
|
|
231
|
+
uikitUtil.css(target, { display: 'block', ...targetProps });
|
|
232
|
+
|
|
233
|
+
// Start transitions on next frame
|
|
234
|
+
requestAnimationFrame(() => {
|
|
235
|
+
const transitions = nodes.
|
|
236
|
+
map(
|
|
237
|
+
(el, i) =>
|
|
238
|
+
uikitUtil.parent(el) === target &&
|
|
239
|
+
uikitUtil.Transition.start(el, propsTo[i], duration, 'ease')).
|
|
240
|
+
|
|
241
|
+
concat(uikitUtil.Transition.start(target, targetPropsTo, duration, 'ease'));
|
|
242
|
+
|
|
243
|
+
Promise.all(transitions).
|
|
244
|
+
then(() => {
|
|
245
|
+
nodes.forEach(
|
|
246
|
+
(el, i) =>
|
|
247
|
+
uikitUtil.parent(el) === target &&
|
|
248
|
+
uikitUtil.css(el, 'display', propsTo[i].opacity === 0 ? 'none' : ''));
|
|
249
|
+
|
|
250
|
+
reset(target);
|
|
251
|
+
}, uikitUtil.noop).
|
|
252
|
+
then(resolve);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
}));
|
|
225
256
|
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
}); });
|
|
229
257
|
}
|
|
230
258
|
|
|
231
259
|
function getProps(el, opacity) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
260
|
+
const zIndex = uikitUtil.css(el, 'zIndex');
|
|
261
|
+
|
|
262
|
+
return uikitUtil.isVisible(el) ?
|
|
263
|
+
{
|
|
264
|
+
display: '',
|
|
265
|
+
opacity: opacity ? uikitUtil.css(el, 'opacity') : '0',
|
|
266
|
+
pointerEvents: 'none',
|
|
267
|
+
position: 'absolute',
|
|
268
|
+
zIndex: zIndex === 'auto' ? uikitUtil.index(el) : zIndex,
|
|
269
|
+
...getPositionWithMargin(el) } :
|
|
270
|
+
|
|
271
|
+
false;
|
|
244
272
|
}
|
|
245
273
|
|
|
246
274
|
function getTransitionProps(target, nodes, currentProps) {
|
|
275
|
+
const propsTo = nodes.map((el, i) =>
|
|
276
|
+
uikitUtil.parent(el) && i in currentProps ?
|
|
277
|
+
currentProps[i] ?
|
|
278
|
+
uikitUtil.isVisible(el) ?
|
|
279
|
+
getPositionWithMargin(el) :
|
|
280
|
+
{ opacity: 0 } :
|
|
281
|
+
{ opacity: uikitUtil.isVisible(el) ? 1 : 0 } :
|
|
282
|
+
false);
|
|
247
283
|
|
|
248
|
-
var propsTo = nodes.map(function (el, i) { return uikitUtil.parent(el) && i in currentProps
|
|
249
|
-
? currentProps[i]
|
|
250
|
-
? uikitUtil.isVisible(el)
|
|
251
|
-
? getPositionWithMargin(el)
|
|
252
|
-
: {opacity: 0}
|
|
253
|
-
: {opacity: uikitUtil.isVisible(el) ? 1 : 0}
|
|
254
|
-
: false; });
|
|
255
|
-
|
|
256
|
-
var propsFrom = propsTo.map(function (props, i) {
|
|
257
284
|
|
|
258
|
-
|
|
285
|
+
const propsFrom = propsTo.map((props, i) => {
|
|
286
|
+
const from = uikitUtil.parent(nodes[i]) === target && (currentProps[i] || getProps(nodes[i]));
|
|
259
287
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
288
|
+
if (!from) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
263
291
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
292
|
+
if (!props) {
|
|
293
|
+
delete from.opacity;
|
|
294
|
+
} else if (!('opacity' in props)) {
|
|
295
|
+
const { opacity } = from;
|
|
268
296
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
297
|
+
if (opacity % 1) {
|
|
298
|
+
props.opacity = 1;
|
|
299
|
+
} else {
|
|
300
|
+
delete from.opacity;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
275
303
|
|
|
276
|
-
|
|
277
|
-
|
|
304
|
+
return from;
|
|
305
|
+
});
|
|
278
306
|
|
|
279
|
-
|
|
307
|
+
return [propsTo, propsFrom];
|
|
280
308
|
}
|
|
281
309
|
|
|
282
310
|
function reset(el) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
311
|
+
uikitUtil.css(el.children, {
|
|
312
|
+
height: '',
|
|
313
|
+
left: '',
|
|
314
|
+
opacity: '',
|
|
315
|
+
pointerEvents: '',
|
|
316
|
+
position: '',
|
|
317
|
+
top: '',
|
|
318
|
+
marginTop: '',
|
|
319
|
+
marginLeft: '',
|
|
320
|
+
transform: '',
|
|
321
|
+
width: '',
|
|
322
|
+
zIndex: '' });
|
|
323
|
+
|
|
324
|
+
uikitUtil.css(el, { height: '', display: '', padding: '' });
|
|
297
325
|
}
|
|
298
326
|
|
|
299
327
|
function getPositionWithMargin(el) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
var left = ref$1.left;
|
|
306
|
-
var ref$2 = uikitUtil.css(el, ['marginTop', 'marginLeft']);
|
|
307
|
-
var marginLeft = ref$2.marginLeft;
|
|
308
|
-
var marginTop = ref$2.marginTop;
|
|
309
|
-
|
|
310
|
-
return {top: top, left: left, height: height, width: width, marginLeft: marginLeft, marginTop: marginTop, transform: ''};
|
|
328
|
+
const { height, width } = uikitUtil.offset(el);
|
|
329
|
+
const { top, left } = uikitUtil.position(el);
|
|
330
|
+
const { marginLeft, marginTop } = uikitUtil.css(el, ['marginTop', 'marginLeft']);
|
|
331
|
+
|
|
332
|
+
return { top, left, height, width, marginLeft, marginTop, transform: '' };
|
|
311
333
|
}
|
|
312
334
|
|
|
313
335
|
var Animate = {
|
|
336
|
+
props: {
|
|
337
|
+
duration: Number,
|
|
338
|
+
animation: Boolean },
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
data: {
|
|
342
|
+
duration: 150,
|
|
343
|
+
animation: 'slide' },
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
methods: {
|
|
347
|
+
animate(action, target) {if (target === void 0) {target = this.$el;}
|
|
348
|
+
const name = this.animation;
|
|
349
|
+
const animationFn =
|
|
350
|
+
name === 'fade' ?
|
|
351
|
+
fade :
|
|
352
|
+
name === 'delayed-fade' ?
|
|
353
|
+
function () {for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}return fade(...args, 40);} :
|
|
354
|
+
name ?
|
|
355
|
+
slide :
|
|
356
|
+
() => {
|
|
357
|
+
action();
|
|
358
|
+
return Promise.resolve();
|
|
359
|
+
};
|
|
314
360
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
},
|
|
319
|
-
|
|
320
|
-
data: {
|
|
321
|
-
duration: 150,
|
|
322
|
-
animation: 'slide'
|
|
323
|
-
},
|
|
324
|
-
|
|
325
|
-
methods: {
|
|
326
|
-
|
|
327
|
-
animate: function(action, target) {
|
|
328
|
-
var this$1$1 = this;
|
|
329
|
-
if ( target === void 0 ) target = this.$el;
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
var name = this.animation;
|
|
333
|
-
var animationFn = name === 'fade'
|
|
334
|
-
? fade
|
|
335
|
-
: name === 'delayed-fade'
|
|
336
|
-
? function () {
|
|
337
|
-
var args = [], len = arguments.length;
|
|
338
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
361
|
+
return animationFn(action, target, this.duration).then(
|
|
362
|
+
() => this.$update(target, 'resize'),
|
|
363
|
+
uikitUtil.noop);
|
|
339
364
|
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
: name
|
|
343
|
-
? slide
|
|
344
|
-
: function () {
|
|
345
|
-
action();
|
|
346
|
-
return uikitUtil.Promise.resolve();
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
return animationFn(action, target, this.duration)
|
|
350
|
-
.then(function () { return this$1$1.$update(target, 'resize'); }, uikitUtil.noop);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
};
|
|
365
|
+
} } };
|
|
355
366
|
|
|
356
367
|
var Class = {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
};
|
|
368
|
+
connected() {
|
|
369
|
+
!uikitUtil.hasClass(this.$el, this.$name) && uikitUtil.addClass(this.$el, this.$name);
|
|
370
|
+
} };
|
|
363
371
|
|
|
364
372
|
var Component = {
|
|
373
|
+
mixins: [Class, Animate],
|
|
374
|
+
|
|
375
|
+
props: {
|
|
376
|
+
group: String,
|
|
377
|
+
threshold: Number,
|
|
378
|
+
clsItem: String,
|
|
379
|
+
clsPlaceholder: String,
|
|
380
|
+
clsDrag: String,
|
|
381
|
+
clsDragState: String,
|
|
382
|
+
clsBase: String,
|
|
383
|
+
clsNoDrag: String,
|
|
384
|
+
clsEmpty: String,
|
|
385
|
+
clsCustom: String,
|
|
386
|
+
handle: String },
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
data: {
|
|
390
|
+
group: false,
|
|
391
|
+
threshold: 5,
|
|
392
|
+
clsItem: 'uk-sortable-item',
|
|
393
|
+
clsPlaceholder: 'uk-sortable-placeholder',
|
|
394
|
+
clsDrag: 'uk-sortable-drag',
|
|
395
|
+
clsDragState: 'uk-drag',
|
|
396
|
+
clsBase: 'uk-sortable',
|
|
397
|
+
clsNoDrag: 'uk-sortable-nodrag',
|
|
398
|
+
clsEmpty: 'uk-sortable-empty',
|
|
399
|
+
clsCustom: '',
|
|
400
|
+
handle: false,
|
|
401
|
+
pos: {} },
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
created() {
|
|
405
|
+
for (const key of ['init', 'start', 'move', 'end']) {
|
|
406
|
+
const fn = this[key];
|
|
407
|
+
this[key] = (e) => {
|
|
408
|
+
uikitUtil.assign(this.pos, uikitUtil.getEventPos(e));
|
|
409
|
+
fn(e);
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
},
|
|
365
413
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
threshold: Number,
|
|
371
|
-
clsItem: String,
|
|
372
|
-
clsPlaceholder: String,
|
|
373
|
-
clsDrag: String,
|
|
374
|
-
clsDragState: String,
|
|
375
|
-
clsBase: String,
|
|
376
|
-
clsNoDrag: String,
|
|
377
|
-
clsEmpty: String,
|
|
378
|
-
clsCustom: String,
|
|
379
|
-
handle: String
|
|
380
|
-
},
|
|
381
|
-
|
|
382
|
-
data: {
|
|
383
|
-
group: false,
|
|
384
|
-
threshold: 5,
|
|
385
|
-
clsItem: 'uk-sortable-item',
|
|
386
|
-
clsPlaceholder: 'uk-sortable-placeholder',
|
|
387
|
-
clsDrag: 'uk-sortable-drag',
|
|
388
|
-
clsDragState: 'uk-drag',
|
|
389
|
-
clsBase: 'uk-sortable',
|
|
390
|
-
clsNoDrag: 'uk-sortable-nodrag',
|
|
391
|
-
clsEmpty: 'uk-sortable-empty',
|
|
392
|
-
clsCustom: '',
|
|
393
|
-
handle: false,
|
|
394
|
-
pos: {}
|
|
395
|
-
},
|
|
414
|
+
events: {
|
|
415
|
+
name: uikitUtil.pointerDown,
|
|
416
|
+
passive: false,
|
|
417
|
+
handler: 'init' },
|
|
396
418
|
|
|
397
|
-
created: function() {
|
|
398
|
-
var this$1$1 = this;
|
|
399
419
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
uikitUtil.assign(this$1$1.pos, uikitUtil.getEventPos(e));
|
|
404
|
-
fn(e);
|
|
405
|
-
};
|
|
406
|
-
});
|
|
420
|
+
computed: {
|
|
421
|
+
target() {
|
|
422
|
+
return (this.$el.tBodies || [this.$el])[0];
|
|
407
423
|
},
|
|
408
424
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
name: uikitUtil.pointerDown,
|
|
412
|
-
passive: false,
|
|
413
|
-
handler: 'init'
|
|
414
|
-
|
|
425
|
+
items() {
|
|
426
|
+
return uikitUtil.children(this.target);
|
|
415
427
|
},
|
|
416
428
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
},
|
|
422
|
-
|
|
423
|
-
items: function() {
|
|
424
|
-
return uikitUtil.children(this.target);
|
|
425
|
-
},
|
|
429
|
+
isEmpty: {
|
|
430
|
+
get() {
|
|
431
|
+
return uikitUtil.isEmpty(this.items);
|
|
432
|
+
},
|
|
426
433
|
|
|
427
|
-
|
|
434
|
+
watch(empty) {
|
|
435
|
+
uikitUtil.toggleClass(this.target, this.clsEmpty, empty);
|
|
436
|
+
},
|
|
428
437
|
|
|
429
|
-
|
|
430
|
-
return uikitUtil.isEmpty(this.items);
|
|
431
|
-
},
|
|
438
|
+
immediate: true },
|
|
432
439
|
|
|
433
|
-
watch: function(empty) {
|
|
434
|
-
uikitUtil.toggleClass(this.target, this.clsEmpty, empty);
|
|
435
|
-
},
|
|
436
440
|
|
|
437
|
-
|
|
441
|
+
handles: {
|
|
442
|
+
get(_ref, el) {let { handle } = _ref;
|
|
443
|
+
return handle ? uikitUtil.$$(handle, el) : this.items;
|
|
444
|
+
},
|
|
438
445
|
|
|
439
|
-
|
|
446
|
+
watch(handles, prev) {
|
|
447
|
+
uikitUtil.css(prev, { touchAction: '', userSelect: '' });
|
|
448
|
+
uikitUtil.css(handles, { touchAction: uikitUtil.hasTouch ? 'none' : '', userSelect: 'none' }); // touchAction set to 'none' causes a performance drop in Chrome 80
|
|
449
|
+
},
|
|
440
450
|
|
|
441
|
-
|
|
451
|
+
immediate: true } },
|
|
442
452
|
|
|
443
|
-
get: function(ref, el) {
|
|
444
|
-
var handle = ref.handle;
|
|
445
453
|
|
|
446
|
-
return handle ? uikitUtil.$$(handle, el) : this.items;
|
|
447
|
-
},
|
|
448
454
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
immediate: true
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
},
|
|
459
|
-
|
|
460
|
-
update: {
|
|
461
|
-
|
|
462
|
-
write: function(data) {
|
|
463
|
-
|
|
464
|
-
if (!this.drag || !uikitUtil.parent(this.placeholder)) {
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
455
|
+
update: {
|
|
456
|
+
write(data) {
|
|
457
|
+
if (!this.drag || !uikitUtil.parent(this.placeholder)) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
467
460
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
var offsetTop = ref_origin.offsetTop;
|
|
474
|
-
var offsetLeft = ref_origin.offsetLeft;
|
|
475
|
-
var placeholder = ref.placeholder;
|
|
461
|
+
const {
|
|
462
|
+
pos: { x, y },
|
|
463
|
+
origin: { offsetTop, offsetLeft },
|
|
464
|
+
placeholder } =
|
|
465
|
+
this;
|
|
476
466
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
});
|
|
467
|
+
uikitUtil.css(this.drag, {
|
|
468
|
+
top: y - offsetTop,
|
|
469
|
+
left: x - offsetLeft });
|
|
481
470
|
|
|
482
|
-
var sortable = this.getSortable(document.elementFromPoint(x, y));
|
|
483
471
|
|
|
484
|
-
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
472
|
+
const sortable = this.getSortable(document.elementFromPoint(x, y));
|
|
487
473
|
|
|
488
|
-
|
|
474
|
+
if (!sortable) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
489
477
|
|
|
490
|
-
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
478
|
+
const { items } = sortable;
|
|
493
479
|
|
|
494
|
-
|
|
480
|
+
if (items.some(uikitUtil.Transition.inProgress)) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
495
483
|
|
|
496
|
-
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
484
|
+
const target = findTarget(items, { x, y });
|
|
499
485
|
|
|
500
|
-
|
|
501
|
-
|
|
486
|
+
if (items.length && (!target || target === placeholder)) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
502
489
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
490
|
+
const previous = this.getSortable(placeholder);
|
|
491
|
+
const insertTarget = findInsertTarget(
|
|
492
|
+
sortable.target,
|
|
493
|
+
target,
|
|
494
|
+
placeholder,
|
|
495
|
+
x,
|
|
496
|
+
y,
|
|
497
|
+
sortable === previous && data.moved !== target);
|
|
506
498
|
|
|
507
|
-
if (insertTarget && placeholder === insertTarget) {
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
499
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
} else {
|
|
515
|
-
delete data.moved;
|
|
516
|
-
}
|
|
500
|
+
if (insertTarget === false) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
517
503
|
|
|
518
|
-
|
|
504
|
+
if (insertTarget && placeholder === insertTarget) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
519
507
|
|
|
520
|
-
|
|
521
|
-
|
|
508
|
+
if (sortable !== previous) {
|
|
509
|
+
previous.remove(placeholder);
|
|
510
|
+
data.moved = target;
|
|
511
|
+
} else {
|
|
512
|
+
delete data.moved;
|
|
513
|
+
}
|
|
522
514
|
|
|
523
|
-
|
|
515
|
+
sortable.insert(placeholder, insertTarget);
|
|
524
516
|
|
|
517
|
+
this.touched.add(sortable);
|
|
525
518
|
},
|
|
526
519
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
init: function(e) {
|
|
530
|
-
|
|
531
|
-
var target = e.target;
|
|
532
|
-
var button = e.button;
|
|
533
|
-
var defaultPrevented = e.defaultPrevented;
|
|
534
|
-
var ref = this.items.filter(function (el) { return uikitUtil.within(target, el); });
|
|
535
|
-
var placeholder = ref[0];
|
|
536
|
-
|
|
537
|
-
if (!placeholder
|
|
538
|
-
|| defaultPrevented
|
|
539
|
-
|| button > 0
|
|
540
|
-
|| uikitUtil.isInput(target)
|
|
541
|
-
|| uikitUtil.within(target, ("." + (this.clsNoDrag)))
|
|
542
|
-
|| this.handle && !uikitUtil.within(target, this.handle)
|
|
543
|
-
) {
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
e.preventDefault();
|
|
520
|
+
events: ['move'] },
|
|
548
521
|
|
|
549
|
-
this.touched = new Set([this]);
|
|
550
|
-
this.placeholder = placeholder;
|
|
551
|
-
this.origin = uikitUtil.assign({target: target, index: uikitUtil.index(placeholder)}, this.pos);
|
|
552
522
|
|
|
553
|
-
|
|
554
|
-
|
|
523
|
+
methods: {
|
|
524
|
+
init(e) {
|
|
525
|
+
const { target, button, defaultPrevented } = e;
|
|
526
|
+
const [placeholder] = this.items.filter((el) => uikitUtil.within(target, el));
|
|
555
527
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
var left = ref.left;
|
|
567
|
-
var top = ref.top;
|
|
568
|
-
uikitUtil.assign(this.origin, {offsetLeft: this.pos.x - left, offsetTop: this.pos.y - top});
|
|
569
|
-
|
|
570
|
-
uikitUtil.addClass(this.drag, this.clsDrag, this.clsCustom);
|
|
571
|
-
uikitUtil.addClass(this.placeholder, this.clsPlaceholder);
|
|
572
|
-
uikitUtil.addClass(this.items, this.clsItem);
|
|
573
|
-
uikitUtil.addClass(document.documentElement, this.clsDragState);
|
|
574
|
-
|
|
575
|
-
uikitUtil.trigger(this.$el, 'start', [this, this.placeholder]);
|
|
576
|
-
|
|
577
|
-
trackScroll(this.pos);
|
|
578
|
-
|
|
579
|
-
this.move(e);
|
|
580
|
-
},
|
|
581
|
-
|
|
582
|
-
move: function(e) {
|
|
583
|
-
|
|
584
|
-
if (this.drag) {
|
|
585
|
-
this.$emit('move');
|
|
586
|
-
} else if (Math.abs(this.pos.x - this.origin.x) > this.threshold || Math.abs(this.pos.y - this.origin.y) > this.threshold) {
|
|
587
|
-
this.start(e);
|
|
588
|
-
}
|
|
528
|
+
if (
|
|
529
|
+
!placeholder ||
|
|
530
|
+
defaultPrevented ||
|
|
531
|
+
button > 0 ||
|
|
532
|
+
uikitUtil.isInput(target) ||
|
|
533
|
+
uikitUtil.within(target, "." + this.clsNoDrag) ||
|
|
534
|
+
this.handle && !uikitUtil.within(target, this.handle))
|
|
535
|
+
{
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
589
538
|
|
|
590
|
-
|
|
539
|
+
e.preventDefault();
|
|
591
540
|
|
|
592
|
-
|
|
593
|
-
|
|
541
|
+
this.touched = new Set([this]);
|
|
542
|
+
this.placeholder = placeholder;
|
|
543
|
+
this.origin = { target, index: uikitUtil.index(placeholder), ...this.pos };
|
|
594
544
|
|
|
545
|
+
uikitUtil.on(document, uikitUtil.pointerMove, this.move);
|
|
546
|
+
uikitUtil.on(document, uikitUtil.pointerUp, this.end);
|
|
595
547
|
|
|
596
|
-
|
|
597
|
-
|
|
548
|
+
if (!this.threshold) {
|
|
549
|
+
this.start(e);
|
|
550
|
+
}
|
|
551
|
+
},
|
|
598
552
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
553
|
+
start(e) {
|
|
554
|
+
this.drag = appendDrag(this.$container, this.placeholder);
|
|
555
|
+
const { left, top } = this.placeholder.getBoundingClientRect();
|
|
556
|
+
uikitUtil.assign(this.origin, { offsetLeft: this.pos.x - left, offsetTop: this.pos.y - top });
|
|
602
557
|
|
|
603
|
-
|
|
558
|
+
uikitUtil.addClass(this.drag, this.clsDrag, this.clsCustom);
|
|
559
|
+
uikitUtil.addClass(this.placeholder, this.clsPlaceholder);
|
|
560
|
+
uikitUtil.addClass(this.items, this.clsItem);
|
|
561
|
+
uikitUtil.addClass(document.documentElement, this.clsDragState);
|
|
604
562
|
|
|
605
|
-
|
|
563
|
+
uikitUtil.trigger(this.$el, 'start', [this, this.placeholder]);
|
|
606
564
|
|
|
607
|
-
|
|
608
|
-
if (this.origin.index !== uikitUtil.index(this.placeholder)) {
|
|
609
|
-
uikitUtil.trigger(this.$el, 'moved', [this, this.placeholder]);
|
|
610
|
-
}
|
|
611
|
-
} else {
|
|
612
|
-
uikitUtil.trigger(sortable.$el, 'added', [sortable, this.placeholder]);
|
|
613
|
-
uikitUtil.trigger(this.$el, 'removed', [this, this.placeholder]);
|
|
614
|
-
}
|
|
565
|
+
trackScroll(this.pos);
|
|
615
566
|
|
|
616
|
-
|
|
567
|
+
this.move(e);
|
|
568
|
+
},
|
|
617
569
|
|
|
618
|
-
|
|
619
|
-
|
|
570
|
+
move(e) {
|
|
571
|
+
if (this.drag) {
|
|
572
|
+
this.$emit('move');
|
|
573
|
+
} else if (
|
|
574
|
+
Math.abs(this.pos.x - this.origin.x) > this.threshold ||
|
|
575
|
+
Math.abs(this.pos.y - this.origin.y) > this.threshold)
|
|
576
|
+
{
|
|
577
|
+
this.start(e);
|
|
578
|
+
}
|
|
579
|
+
},
|
|
620
580
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
581
|
+
end() {
|
|
582
|
+
uikitUtil.off(document, uikitUtil.pointerMove, this.move);
|
|
583
|
+
uikitUtil.off(document, uikitUtil.pointerUp, this.end);
|
|
624
584
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
);
|
|
629
|
-
this.touched = null;
|
|
630
|
-
uikitUtil.removeClass(document.documentElement, this.clsDragState);
|
|
585
|
+
if (!this.drag) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
631
588
|
|
|
632
|
-
|
|
589
|
+
untrackScroll();
|
|
633
590
|
|
|
634
|
-
|
|
635
|
-
var this$1$1 = this;
|
|
591
|
+
const sortable = this.getSortable(this.placeholder);
|
|
636
592
|
|
|
593
|
+
if (this === sortable) {
|
|
594
|
+
if (this.origin.index !== uikitUtil.index(this.placeholder)) {
|
|
595
|
+
uikitUtil.trigger(this.$el, 'moved', [this, this.placeholder]);
|
|
596
|
+
}
|
|
597
|
+
} else {
|
|
598
|
+
uikitUtil.trigger(sortable.$el, 'added', [sortable, this.placeholder]);
|
|
599
|
+
uikitUtil.trigger(this.$el, 'removed', [this, this.placeholder]);
|
|
600
|
+
}
|
|
637
601
|
|
|
638
|
-
|
|
602
|
+
uikitUtil.trigger(this.$el, 'stop', [this, this.placeholder]);
|
|
639
603
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
: uikitUtil.append(this$1$1.target, element); };
|
|
604
|
+
uikitUtil.remove(this.drag);
|
|
605
|
+
this.drag = null;
|
|
643
606
|
|
|
644
|
-
|
|
607
|
+
for (const { clsPlaceholder, clsItem } of this.touched) {
|
|
608
|
+
for (const sortable of this.touched) {
|
|
609
|
+
uikitUtil.removeClass(sortable.items, clsPlaceholder, clsItem);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
this.touched = null;
|
|
613
|
+
uikitUtil.removeClass(document.documentElement, this.clsDragState);
|
|
614
|
+
},
|
|
645
615
|
|
|
646
|
-
|
|
616
|
+
insert(element, target) {
|
|
617
|
+
uikitUtil.addClass(this.items, this.clsItem);
|
|
647
618
|
|
|
648
|
-
|
|
619
|
+
const insert = () => target ? uikitUtil.before(target, element) : uikitUtil.append(this.target, element);
|
|
649
620
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
}
|
|
621
|
+
this.animate(insert);
|
|
622
|
+
},
|
|
653
623
|
|
|
654
|
-
|
|
624
|
+
remove(element) {
|
|
625
|
+
if (!uikitUtil.within(element, this.target)) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
655
628
|
|
|
656
|
-
|
|
629
|
+
this.animate(() => uikitUtil.remove(element));
|
|
630
|
+
},
|
|
657
631
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
632
|
+
getSortable(element) {
|
|
633
|
+
do {
|
|
634
|
+
const sortable = this.$getComponent(element, 'sortable');
|
|
661
635
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
636
|
+
if (
|
|
637
|
+
sortable && (
|
|
638
|
+
sortable === this || this.group !== false && sortable.group === this.group))
|
|
639
|
+
{
|
|
640
|
+
return sortable;
|
|
666
641
|
}
|
|
642
|
+
} while (element = uikitUtil.parent(element));
|
|
643
|
+
} } };
|
|
667
644
|
|
|
668
|
-
}
|
|
669
645
|
|
|
670
|
-
};
|
|
671
646
|
|
|
672
|
-
|
|
647
|
+
let trackTimer;
|
|
673
648
|
function trackScroll(pos) {
|
|
649
|
+
let last = Date.now();
|
|
650
|
+
trackTimer = setInterval(() => {
|
|
651
|
+
let { x, y } = pos;
|
|
652
|
+
y += uikitUtil.scrollTop(window);
|
|
653
|
+
|
|
654
|
+
const dist = (Date.now() - last) * 0.3;
|
|
655
|
+
last = Date.now();
|
|
656
|
+
|
|
657
|
+
uikitUtil.scrollParents(document.elementFromPoint(x, pos.y), /auto|scroll/).
|
|
658
|
+
reverse().
|
|
659
|
+
some((scrollEl) => {
|
|
660
|
+
let { scrollTop: scroll, scrollHeight } = scrollEl;
|
|
661
|
+
|
|
662
|
+
const { top, bottom, height } = uikitUtil.offset(uikitUtil.getViewport(scrollEl));
|
|
663
|
+
|
|
664
|
+
if (top < y && top + 35 > y) {
|
|
665
|
+
scroll -= dist;
|
|
666
|
+
} else if (bottom > y && bottom - 35 < y) {
|
|
667
|
+
scroll += dist;
|
|
668
|
+
} else {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
674
671
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
var dist = (Date.now() - last) * .3;
|
|
683
|
-
last = Date.now();
|
|
684
|
-
|
|
685
|
-
uikitUtil.scrollParents(document.elementFromPoint(x, pos.y), /auto|scroll/).reverse().some(function (scrollEl) {
|
|
686
|
-
|
|
687
|
-
var scroll = scrollEl.scrollTop;
|
|
688
|
-
var scrollHeight = scrollEl.scrollHeight;
|
|
689
|
-
|
|
690
|
-
var ref = uikitUtil.offset(uikitUtil.getViewport(scrollEl));
|
|
691
|
-
var top = ref.top;
|
|
692
|
-
var bottom = ref.bottom;
|
|
693
|
-
var height = ref.height;
|
|
694
|
-
|
|
695
|
-
if (top < y && top + 35 > y) {
|
|
696
|
-
scroll -= dist;
|
|
697
|
-
} else if (bottom > y && bottom - 35 < y) {
|
|
698
|
-
scroll += dist;
|
|
699
|
-
} else {
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
if (scroll > 0 && scroll < scrollHeight - height) {
|
|
704
|
-
uikitUtil.scrollTop(scrollEl, scroll);
|
|
705
|
-
return true;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
});
|
|
709
|
-
|
|
710
|
-
}, 15);
|
|
711
|
-
|
|
672
|
+
if (scroll > 0 && scroll < scrollHeight - height) {
|
|
673
|
+
uikitUtil.scrollTop(scrollEl, scroll);
|
|
674
|
+
return true;
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
}, 15);
|
|
712
678
|
}
|
|
713
679
|
|
|
714
680
|
function untrackScroll() {
|
|
715
|
-
|
|
681
|
+
clearInterval(trackTimer);
|
|
716
682
|
}
|
|
717
683
|
|
|
718
684
|
function appendDrag(container, element) {
|
|
719
|
-
|
|
685
|
+
const clone = uikitUtil.append(
|
|
686
|
+
container,
|
|
687
|
+
element.outerHTML.replace(/(^<)(?:li|tr)|(?:li|tr)(\/>$)/g, '$1div$2'));
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
uikitUtil.css(clone, 'margin', '0', 'important');
|
|
691
|
+
uikitUtil.css(clone, {
|
|
692
|
+
boxSizing: 'border-box',
|
|
693
|
+
width: element.offsetWidth,
|
|
694
|
+
height: element.offsetHeight,
|
|
695
|
+
padding: uikitUtil.css(element, 'padding') });
|
|
720
696
|
|
|
721
|
-
uikitUtil.css(clone, 'margin', '0', 'important');
|
|
722
|
-
uikitUtil.css(clone, uikitUtil.assign({
|
|
723
|
-
boxSizing: 'border-box',
|
|
724
|
-
width: element.offsetWidth,
|
|
725
|
-
height: element.offsetHeight
|
|
726
|
-
}, uikitUtil.css(element, ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom'])));
|
|
727
697
|
|
|
728
|
-
|
|
698
|
+
uikitUtil.height(clone.firstElementChild, uikitUtil.height(element.firstElementChild));
|
|
729
699
|
|
|
730
|
-
|
|
700
|
+
return clone;
|
|
731
701
|
}
|
|
732
702
|
|
|
733
703
|
function findTarget(items, point) {
|
|
734
|
-
|
|
704
|
+
return items[uikitUtil.findIndex(items, (item) => uikitUtil.pointInRect(point, item.getBoundingClientRect()))];
|
|
735
705
|
}
|
|
736
706
|
|
|
737
707
|
function findInsertTarget(list, target, placeholder, x, y, sameList) {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
708
|
+
if (!uikitUtil.children(list).length) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
const rect = target.getBoundingClientRect();
|
|
713
|
+
if (!sameList) {
|
|
714
|
+
if (!isHorizontal(list, placeholder)) {
|
|
715
|
+
return y < rect.top + rect.height / 2 ? target : target.nextElementSibling;
|
|
741
716
|
}
|
|
742
717
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
if (!isHorizontal(list, placeholder)) {
|
|
747
|
-
return y < rect.top + rect.height / 2
|
|
748
|
-
? target
|
|
749
|
-
: target.nextElementSibling;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
return target;
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
var placeholderRect = placeholder.getBoundingClientRect();
|
|
756
|
-
var sameRow = linesIntersect(
|
|
757
|
-
[rect.top, rect.bottom],
|
|
758
|
-
[placeholderRect.top, placeholderRect.bottom]
|
|
759
|
-
);
|
|
718
|
+
return target;
|
|
719
|
+
}
|
|
760
720
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
721
|
+
const placeholderRect = placeholder.getBoundingClientRect();
|
|
722
|
+
const sameRow = linesIntersect(
|
|
723
|
+
[rect.top, rect.bottom],
|
|
724
|
+
[placeholderRect.top, placeholderRect.bottom]);
|
|
765
725
|
|
|
766
|
-
var diff = placeholderRect[lengthProp] < rect[lengthProp] ? rect[lengthProp] - placeholderRect[lengthProp] : 0;
|
|
767
726
|
|
|
768
|
-
|
|
727
|
+
const pointerPos = sameRow ? x : y;
|
|
728
|
+
const lengthProp = sameRow ? 'width' : 'height';
|
|
729
|
+
const startProp = sameRow ? 'left' : 'top';
|
|
730
|
+
const endProp = sameRow ? 'right' : 'bottom';
|
|
769
731
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
732
|
+
const diff =
|
|
733
|
+
placeholderRect[lengthProp] < rect[lengthProp] ?
|
|
734
|
+
rect[lengthProp] - placeholderRect[lengthProp] :
|
|
735
|
+
0;
|
|
773
736
|
|
|
774
|
-
|
|
737
|
+
if (placeholderRect[startProp] < rect[startProp]) {
|
|
738
|
+
if (diff && pointerPos < rect[startProp] + diff) {
|
|
739
|
+
return false;
|
|
775
740
|
}
|
|
776
741
|
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
}
|
|
742
|
+
return target.nextElementSibling;
|
|
743
|
+
}
|
|
780
744
|
|
|
781
|
-
|
|
745
|
+
if (diff && pointerPos > rect[endProp] - diff) {
|
|
746
|
+
return false;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
return target;
|
|
782
750
|
}
|
|
783
751
|
|
|
784
752
|
function isHorizontal(list, placeholder) {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
return !linesIntersect([rectA.left, rectA.right], [rectB.left, rectB.right]);
|
|
798
|
-
});
|
|
753
|
+
const single = uikitUtil.children(list).length === 1;
|
|
754
|
+
|
|
755
|
+
if (single) {
|
|
756
|
+
uikitUtil.append(list, placeholder);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
const items = uikitUtil.children(list);
|
|
760
|
+
const isHorizontal = items.some((el, i) => {
|
|
761
|
+
const rectA = el.getBoundingClientRect();
|
|
762
|
+
return items.slice(i + 1).some((el) => {
|
|
763
|
+
const rectB = el.getBoundingClientRect();
|
|
764
|
+
return !linesIntersect([rectA.left, rectA.right], [rectB.left, rectB.right]);
|
|
799
765
|
});
|
|
766
|
+
});
|
|
800
767
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
768
|
+
if (single) {
|
|
769
|
+
uikitUtil.remove(placeholder);
|
|
770
|
+
}
|
|
804
771
|
|
|
805
|
-
|
|
772
|
+
return isHorizontal;
|
|
806
773
|
}
|
|
807
774
|
|
|
808
775
|
function linesIntersect(lineA, lineB) {
|
|
809
|
-
|
|
776
|
+
return lineA[1] > lineB[0] && lineB[1] > lineA[0];
|
|
810
777
|
}
|
|
811
778
|
|
|
812
779
|
if (typeof window !== 'undefined' && window.UIkit) {
|
|
813
|
-
|
|
780
|
+
window.UIkit.component('sortable', Component);
|
|
814
781
|
}
|
|
815
782
|
|
|
816
783
|
return Component;
|