uikit 3.11.2-dev.fb043abc2 → 3.12.2
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 +63 -20
- 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 +144 -202
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +144 -202
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +146 -208
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +146 -208
- package/dist/css/uikit.min.css +1 -1
- package/dist/js/components/countdown.js +66 -138
- 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 +1091 -1319
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +1137 -1396
- 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 +347 -361
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +345 -360
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +749 -843
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +345 -360
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +628 -798
- 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 +156 -167
- package/dist/js/components/upload.min.js +1 -1
- package/dist/js/uikit-core.js +5317 -6554
- 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 +8018 -9698
- 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 +199 -187
- package/src/js/components/countdown.js +32 -85
- 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 +9 -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 +117 -89
- 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 +53 -63
- package/src/js/core/accordion.js +58 -48
- package/src/js/core/alert.js +9 -17
- package/src/js/core/core.js +17 -69
- package/src/js/core/cover.js +15 -15
- package/src/js/core/drop.js +110 -94
- package/src/js/core/form-custom.js +22 -27
- 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 +30 -34
- package/src/js/core/icon.js +47 -52
- package/src/js/core/img.js +153 -143
- 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 +113 -85
- package/src/js/core/offcanvas.js +51 -54
- 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 +161 -128
- package/src/js/core/svg.js +68 -83
- package/src/js/core/switcher.js +56 -47
- package/src/js/core/tab.js +7 -10
- package/src/js/core/toggle.js +69 -68
- package/src/js/core/video.js +22 -21
- 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/lazyload.js +20 -0
- package/src/js/mixin/media.js +5 -10
- package/src/js/mixin/modal.js +89 -66
- package/src/js/mixin/parallax.js +149 -107
- 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 +47 -60
- package/src/js/mixin/slideshow.js +12 -22
- package/src/js/mixin/swipe.js +72 -0
- 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 +25 -40
- 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 +58 -45
- package/src/js/util/dom.js +37 -66
- 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 +18 -36
- package/src/js/util/index.js +1 -1
- package/src/js/util/lang.js +82 -121
- package/src/js/util/mouse.js +19 -17
- package/src/js/util/observer.js +36 -0
- package/src/js/util/options.js +35 -49
- 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/height.less +3 -0
- package/src/less/components/leader.less +0 -1
- package/src/less/components/lightbox.less +0 -1
- package/src/less/components/list.less +5 -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 +3 -3
- package/src/less/components/slideshow.less +3 -3
- package/src/less/components/text.less +16 -32
- package/src/less/components/utility.less +25 -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/height.scss +3 -0
- 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/list.scss +5 -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 +3 -3
- package/src/scss/components/slideshow.scss +3 -3
- package/src/scss/components/text.scss +16 -32
- package/src/scss/components/utility.scss +25 -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/countdown.html +10 -8
- package/tests/dotnav.html +3 -3
- package/tests/image.html +296 -64
- 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 +16 -7
- 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 +57 -72
- package/tests/sticky.html +14 -3
- 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 +50 -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
|
@@ -1,9 +1,40 @@
|
|
|
1
1
|
import Animate from '../mixin/animate';
|
|
2
2
|
import Class from '../mixin/class';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
$$,
|
|
5
|
+
addClass,
|
|
6
|
+
append,
|
|
7
|
+
assign,
|
|
8
|
+
before,
|
|
9
|
+
children,
|
|
10
|
+
css,
|
|
11
|
+
findIndex,
|
|
12
|
+
getEventPos,
|
|
13
|
+
getViewport,
|
|
14
|
+
hasTouch,
|
|
15
|
+
height,
|
|
16
|
+
index,
|
|
17
|
+
isEmpty,
|
|
18
|
+
isInput,
|
|
19
|
+
off,
|
|
20
|
+
offset,
|
|
21
|
+
on,
|
|
22
|
+
parent,
|
|
23
|
+
pointerDown,
|
|
24
|
+
pointerMove,
|
|
25
|
+
pointerUp,
|
|
26
|
+
pointInRect,
|
|
27
|
+
remove,
|
|
28
|
+
removeClass,
|
|
29
|
+
scrollParents,
|
|
30
|
+
scrollTop,
|
|
31
|
+
toggleClass,
|
|
32
|
+
Transition,
|
|
33
|
+
trigger,
|
|
34
|
+
within,
|
|
35
|
+
} from 'uikit-util';
|
|
4
36
|
|
|
5
37
|
export default {
|
|
6
|
-
|
|
7
38
|
mixins: [Class, Animate],
|
|
8
39
|
|
|
9
40
|
props: {
|
|
@@ -17,7 +48,7 @@ export default {
|
|
|
17
48
|
clsNoDrag: String,
|
|
18
49
|
clsEmpty: String,
|
|
19
50
|
clsCustom: String,
|
|
20
|
-
handle: String
|
|
51
|
+
handle: String,
|
|
21
52
|
},
|
|
22
53
|
|
|
23
54
|
data: {
|
|
@@ -32,29 +63,26 @@ export default {
|
|
|
32
63
|
clsEmpty: 'uk-sortable-empty',
|
|
33
64
|
clsCustom: '',
|
|
34
65
|
handle: false,
|
|
35
|
-
pos: {}
|
|
66
|
+
pos: {},
|
|
36
67
|
},
|
|
37
68
|
|
|
38
69
|
created() {
|
|
39
|
-
['init', 'start', 'move', 'end']
|
|
70
|
+
for (const key of ['init', 'start', 'move', 'end']) {
|
|
40
71
|
const fn = this[key];
|
|
41
|
-
this[key] = e => {
|
|
72
|
+
this[key] = (e) => {
|
|
42
73
|
assign(this.pos, getEventPos(e));
|
|
43
74
|
fn(e);
|
|
44
75
|
};
|
|
45
|
-
}
|
|
76
|
+
}
|
|
46
77
|
},
|
|
47
78
|
|
|
48
79
|
events: {
|
|
49
|
-
|
|
50
80
|
name: pointerDown,
|
|
51
81
|
passive: false,
|
|
52
|
-
handler: 'init'
|
|
53
|
-
|
|
82
|
+
handler: 'init',
|
|
54
83
|
},
|
|
55
84
|
|
|
56
85
|
computed: {
|
|
57
|
-
|
|
58
86
|
target() {
|
|
59
87
|
return (this.$el.tBodies || [this.$el])[0];
|
|
60
88
|
},
|
|
@@ -64,7 +92,6 @@ export default {
|
|
|
64
92
|
},
|
|
65
93
|
|
|
66
94
|
isEmpty: {
|
|
67
|
-
|
|
68
95
|
get() {
|
|
69
96
|
return isEmpty(this.items);
|
|
70
97
|
},
|
|
@@ -73,40 +100,38 @@ export default {
|
|
|
73
100
|
toggleClass(this.target, this.clsEmpty, empty);
|
|
74
101
|
},
|
|
75
102
|
|
|
76
|
-
immediate: true
|
|
77
|
-
|
|
103
|
+
immediate: true,
|
|
78
104
|
},
|
|
79
105
|
|
|
80
106
|
handles: {
|
|
81
|
-
|
|
82
|
-
get({handle}, el) {
|
|
107
|
+
get({ handle }, el) {
|
|
83
108
|
return handle ? $$(handle, el) : this.items;
|
|
84
109
|
},
|
|
85
110
|
|
|
86
111
|
watch(handles, prev) {
|
|
87
|
-
css(prev, {touchAction: '', userSelect: ''});
|
|
88
|
-
css(handles, {touchAction: hasTouch ? 'none' : '', userSelect: 'none'}); // touchAction set to 'none' causes a performance drop in Chrome 80
|
|
112
|
+
css(prev, { touchAction: '', userSelect: '' });
|
|
113
|
+
css(handles, { touchAction: hasTouch ? 'none' : '', userSelect: 'none' }); // touchAction set to 'none' causes a performance drop in Chrome 80
|
|
89
114
|
},
|
|
90
115
|
|
|
91
|
-
immediate: true
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
116
|
+
immediate: true,
|
|
117
|
+
},
|
|
95
118
|
},
|
|
96
119
|
|
|
97
120
|
update: {
|
|
98
|
-
|
|
99
121
|
write(data) {
|
|
100
|
-
|
|
101
122
|
if (!this.drag || !parent(this.placeholder)) {
|
|
102
123
|
return;
|
|
103
124
|
}
|
|
104
125
|
|
|
105
|
-
const {
|
|
126
|
+
const {
|
|
127
|
+
pos: { x, y },
|
|
128
|
+
origin: { offsetTop, offsetLeft },
|
|
129
|
+
placeholder,
|
|
130
|
+
} = this;
|
|
106
131
|
|
|
107
132
|
css(this.drag, {
|
|
108
133
|
top: y - offsetTop,
|
|
109
|
-
left: x - offsetLeft
|
|
134
|
+
left: x - offsetLeft,
|
|
110
135
|
});
|
|
111
136
|
|
|
112
137
|
const sortable = this.getSortable(document.elementFromPoint(x, y));
|
|
@@ -115,20 +140,27 @@ export default {
|
|
|
115
140
|
return;
|
|
116
141
|
}
|
|
117
142
|
|
|
118
|
-
const {items} = sortable;
|
|
143
|
+
const { items } = sortable;
|
|
119
144
|
|
|
120
145
|
if (items.some(Transition.inProgress)) {
|
|
121
146
|
return;
|
|
122
147
|
}
|
|
123
148
|
|
|
124
|
-
const target = findTarget(items, {x, y});
|
|
149
|
+
const target = findTarget(items, { x, y });
|
|
125
150
|
|
|
126
151
|
if (items.length && (!target || target === placeholder)) {
|
|
127
152
|
return;
|
|
128
153
|
}
|
|
129
154
|
|
|
130
155
|
const previous = this.getSortable(placeholder);
|
|
131
|
-
const insertTarget = findInsertTarget(
|
|
156
|
+
const insertTarget = findInsertTarget(
|
|
157
|
+
sortable.target,
|
|
158
|
+
target,
|
|
159
|
+
placeholder,
|
|
160
|
+
x,
|
|
161
|
+
y,
|
|
162
|
+
sortable === previous && data.moved !== target
|
|
163
|
+
);
|
|
132
164
|
|
|
133
165
|
if (insertTarget === false) {
|
|
134
166
|
return;
|
|
@@ -150,23 +182,21 @@ export default {
|
|
|
150
182
|
this.touched.add(sortable);
|
|
151
183
|
},
|
|
152
184
|
|
|
153
|
-
events: ['move']
|
|
154
|
-
|
|
185
|
+
events: ['move'],
|
|
155
186
|
},
|
|
156
187
|
|
|
157
188
|
methods: {
|
|
158
|
-
|
|
159
189
|
init(e) {
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
||
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
190
|
+
const { target, button, defaultPrevented } = e;
|
|
191
|
+
const [placeholder] = this.items.filter((el) => within(target, el));
|
|
192
|
+
|
|
193
|
+
if (
|
|
194
|
+
!placeholder ||
|
|
195
|
+
defaultPrevented ||
|
|
196
|
+
button > 0 ||
|
|
197
|
+
isInput(target) ||
|
|
198
|
+
within(target, `.${this.clsNoDrag}`) ||
|
|
199
|
+
(this.handle && !within(target, this.handle))
|
|
170
200
|
) {
|
|
171
201
|
return;
|
|
172
202
|
}
|
|
@@ -175,7 +205,7 @@ export default {
|
|
|
175
205
|
|
|
176
206
|
this.touched = new Set([this]);
|
|
177
207
|
this.placeholder = placeholder;
|
|
178
|
-
this.origin =
|
|
208
|
+
this.origin = { target, index: index(placeholder), ...this.pos };
|
|
179
209
|
|
|
180
210
|
on(document, pointerMove, this.move);
|
|
181
211
|
on(document, pointerUp, this.end);
|
|
@@ -183,14 +213,12 @@ export default {
|
|
|
183
213
|
if (!this.threshold) {
|
|
184
214
|
this.start(e);
|
|
185
215
|
}
|
|
186
|
-
|
|
187
216
|
},
|
|
188
217
|
|
|
189
218
|
start(e) {
|
|
190
|
-
|
|
191
219
|
this.drag = appendDrag(this.$container, this.placeholder);
|
|
192
|
-
const {left, top} = this.placeholder.getBoundingClientRect();
|
|
193
|
-
assign(this.origin, {offsetLeft: this.pos.x - left, offsetTop: this.pos.y - top});
|
|
220
|
+
const { left, top } = this.placeholder.getBoundingClientRect();
|
|
221
|
+
assign(this.origin, { offsetLeft: this.pos.x - left, offsetTop: this.pos.y - top });
|
|
194
222
|
|
|
195
223
|
addClass(this.drag, this.clsDrag, this.clsCustom);
|
|
196
224
|
addClass(this.placeholder, this.clsPlaceholder);
|
|
@@ -205,17 +233,17 @@ export default {
|
|
|
205
233
|
},
|
|
206
234
|
|
|
207
235
|
move(e) {
|
|
208
|
-
|
|
209
236
|
if (this.drag) {
|
|
210
237
|
this.$emit('move');
|
|
211
|
-
} else if (
|
|
238
|
+
} else if (
|
|
239
|
+
Math.abs(this.pos.x - this.origin.x) > this.threshold ||
|
|
240
|
+
Math.abs(this.pos.y - this.origin.y) > this.threshold
|
|
241
|
+
) {
|
|
212
242
|
this.start(e);
|
|
213
243
|
}
|
|
214
|
-
|
|
215
244
|
},
|
|
216
245
|
|
|
217
246
|
end() {
|
|
218
|
-
|
|
219
247
|
off(document, pointerMove, this.move);
|
|
220
248
|
off(document, pointerUp, this.end);
|
|
221
249
|
|
|
@@ -241,87 +269,77 @@ export default {
|
|
|
241
269
|
remove(this.drag);
|
|
242
270
|
this.drag = null;
|
|
243
271
|
|
|
244
|
-
|
|
245
|
-
this.touched
|
|
246
|
-
removeClass(sortable.items, clsPlaceholder, clsItem)
|
|
247
|
-
|
|
248
|
-
|
|
272
|
+
for (const { clsPlaceholder, clsItem } of this.touched) {
|
|
273
|
+
for (const sortable of this.touched) {
|
|
274
|
+
removeClass(sortable.items, clsPlaceholder, clsItem);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
249
277
|
this.touched = null;
|
|
250
278
|
removeClass(document.documentElement, this.clsDragState);
|
|
251
|
-
|
|
252
279
|
},
|
|
253
280
|
|
|
254
281
|
insert(element, target) {
|
|
255
|
-
|
|
256
282
|
addClass(this.items, this.clsItem);
|
|
257
283
|
|
|
258
|
-
const insert = () => target
|
|
259
|
-
? before(target, element)
|
|
260
|
-
: append(this.target, element);
|
|
284
|
+
const insert = () => (target ? before(target, element) : append(this.target, element));
|
|
261
285
|
|
|
262
286
|
this.animate(insert);
|
|
263
|
-
|
|
264
287
|
},
|
|
265
288
|
|
|
266
289
|
remove(element) {
|
|
267
|
-
|
|
268
290
|
if (!within(element, this.target)) {
|
|
269
291
|
return;
|
|
270
292
|
}
|
|
271
293
|
|
|
272
294
|
this.animate(() => remove(element));
|
|
273
|
-
|
|
274
295
|
},
|
|
275
296
|
|
|
276
297
|
getSortable(element) {
|
|
277
298
|
do {
|
|
278
299
|
const sortable = this.$getComponent(element, 'sortable');
|
|
279
300
|
|
|
280
|
-
if (
|
|
301
|
+
if (
|
|
302
|
+
sortable &&
|
|
303
|
+
(sortable === this || (this.group !== false && sortable.group === this.group))
|
|
304
|
+
) {
|
|
281
305
|
return sortable;
|
|
282
306
|
}
|
|
283
307
|
} while ((element = parent(element)));
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
308
|
+
},
|
|
309
|
+
},
|
|
288
310
|
};
|
|
289
311
|
|
|
290
312
|
let trackTimer;
|
|
291
313
|
function trackScroll(pos) {
|
|
292
|
-
|
|
293
314
|
let last = Date.now();
|
|
294
315
|
trackTimer = setInterval(() => {
|
|
295
|
-
|
|
296
|
-
let {x, y} = pos;
|
|
316
|
+
let { x, y } = pos;
|
|
297
317
|
y += scrollTop(window);
|
|
298
318
|
|
|
299
|
-
const dist = (Date.now() - last) * .3;
|
|
319
|
+
const dist = (Date.now() - last) * 0.3;
|
|
300
320
|
last = Date.now();
|
|
301
321
|
|
|
302
|
-
scrollParents(document.elementFromPoint(x, pos.y), /auto|scroll/)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
const {top, bottom, height} = offset(getViewport(scrollEl));
|
|
307
|
-
|
|
308
|
-
if (top < y && top + 35 > y) {
|
|
309
|
-
scroll -= dist;
|
|
310
|
-
} else if (bottom > y && bottom - 35 < y) {
|
|
311
|
-
scroll += dist;
|
|
312
|
-
} else {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
322
|
+
scrollParents(document.elementFromPoint(x, pos.y), /auto|scroll/)
|
|
323
|
+
.reverse()
|
|
324
|
+
.some((scrollEl) => {
|
|
325
|
+
let { scrollTop: scroll, scrollHeight } = scrollEl;
|
|
315
326
|
|
|
316
|
-
|
|
317
|
-
scrollTop(scrollEl, scroll);
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
327
|
+
const { top, bottom, height } = offset(getViewport(scrollEl));
|
|
320
328
|
|
|
321
|
-
|
|
329
|
+
if (top < y && top + 35 > y) {
|
|
330
|
+
scroll -= dist;
|
|
331
|
+
} else if (bottom > y && bottom - 35 < y) {
|
|
332
|
+
scroll += dist;
|
|
333
|
+
} else {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
322
336
|
|
|
337
|
+
if (scroll > 0 && scroll < scrollHeight - height) {
|
|
338
|
+
scrollTop(scrollEl, scroll);
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
});
|
|
323
342
|
}, 15);
|
|
324
|
-
|
|
325
343
|
}
|
|
326
344
|
|
|
327
345
|
function untrackScroll() {
|
|
@@ -329,14 +347,18 @@ function untrackScroll() {
|
|
|
329
347
|
}
|
|
330
348
|
|
|
331
349
|
function appendDrag(container, element) {
|
|
332
|
-
const clone = append(
|
|
350
|
+
const clone = append(
|
|
351
|
+
container,
|
|
352
|
+
element.outerHTML.replace(/(^<)(?:li|tr)|(?:li|tr)(\/>$)/g, '$1div$2')
|
|
353
|
+
);
|
|
333
354
|
|
|
334
355
|
css(clone, 'margin', '0', 'important');
|
|
335
|
-
css(clone,
|
|
356
|
+
css(clone, {
|
|
336
357
|
boxSizing: 'border-box',
|
|
337
358
|
width: element.offsetWidth,
|
|
338
|
-
height: element.offsetHeight
|
|
339
|
-
|
|
359
|
+
height: element.offsetHeight,
|
|
360
|
+
padding: css(element, 'padding'),
|
|
361
|
+
});
|
|
340
362
|
|
|
341
363
|
height(clone.firstElementChild, height(element.firstElementChild));
|
|
342
364
|
|
|
@@ -344,22 +366,18 @@ function appendDrag(container, element) {
|
|
|
344
366
|
}
|
|
345
367
|
|
|
346
368
|
function findTarget(items, point) {
|
|
347
|
-
return items[findIndex(items, item => pointInRect(point, item.getBoundingClientRect()))];
|
|
369
|
+
return items[findIndex(items, (item) => pointInRect(point, item.getBoundingClientRect()))];
|
|
348
370
|
}
|
|
349
371
|
|
|
350
372
|
function findInsertTarget(list, target, placeholder, x, y, sameList) {
|
|
351
|
-
|
|
352
373
|
if (!children(list).length) {
|
|
353
374
|
return;
|
|
354
375
|
}
|
|
355
376
|
|
|
356
377
|
const rect = target.getBoundingClientRect();
|
|
357
378
|
if (!sameList) {
|
|
358
|
-
|
|
359
379
|
if (!isHorizontal(list, placeholder)) {
|
|
360
|
-
return y < rect.top + rect.height / 2
|
|
361
|
-
? target
|
|
362
|
-
: target.nextElementSibling;
|
|
380
|
+
return y < rect.top + rect.height / 2 ? target : target.nextElementSibling;
|
|
363
381
|
}
|
|
364
382
|
|
|
365
383
|
return target;
|
|
@@ -376,10 +394,12 @@ function findInsertTarget(list, target, placeholder, x, y, sameList) {
|
|
|
376
394
|
const startProp = sameRow ? 'left' : 'top';
|
|
377
395
|
const endProp = sameRow ? 'right' : 'bottom';
|
|
378
396
|
|
|
379
|
-
const diff =
|
|
397
|
+
const diff =
|
|
398
|
+
placeholderRect[lengthProp] < rect[lengthProp]
|
|
399
|
+
? rect[lengthProp] - placeholderRect[lengthProp]
|
|
400
|
+
: 0;
|
|
380
401
|
|
|
381
402
|
if (placeholderRect[startProp] < rect[startProp]) {
|
|
382
|
-
|
|
383
403
|
if (diff && pointerPos < rect[startProp] + diff) {
|
|
384
404
|
return false;
|
|
385
405
|
}
|
|
@@ -395,7 +415,6 @@ function findInsertTarget(list, target, placeholder, x, y, sameList) {
|
|
|
395
415
|
}
|
|
396
416
|
|
|
397
417
|
function isHorizontal(list, placeholder) {
|
|
398
|
-
|
|
399
418
|
const single = children(list).length === 1;
|
|
400
419
|
|
|
401
420
|
if (single) {
|
|
@@ -405,7 +424,7 @@ function isHorizontal(list, placeholder) {
|
|
|
405
424
|
const items = children(list);
|
|
406
425
|
const isHorizontal = items.some((el, i) => {
|
|
407
426
|
const rectA = el.getBoundingClientRect();
|
|
408
|
-
return items.slice(i + 1).some(el => {
|
|
427
|
+
return items.slice(i + 1).some((el) => {
|
|
409
428
|
const rectB = el.getBoundingClientRect();
|
|
410
429
|
return !linesIntersect([rectA.left, rectA.right], [rectB.left, rectB.right]);
|
|
411
430
|
});
|
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import Container from '../mixin/container';
|
|
2
2
|
import Togglable from '../mixin/togglable';
|
|
3
3
|
import Position from '../mixin/position';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
append,
|
|
6
|
+
attr,
|
|
7
|
+
flipPosition,
|
|
8
|
+
hasAttr,
|
|
9
|
+
isFocusable,
|
|
10
|
+
isTouch,
|
|
11
|
+
matches,
|
|
12
|
+
on,
|
|
13
|
+
once,
|
|
14
|
+
pointerDown,
|
|
15
|
+
pointerEnter,
|
|
16
|
+
pointerLeave,
|
|
17
|
+
remove,
|
|
18
|
+
within,
|
|
19
|
+
} from 'uikit-util';
|
|
5
20
|
|
|
6
21
|
export default {
|
|
7
|
-
|
|
8
22
|
mixins: [Container, Togglable, Position],
|
|
9
23
|
|
|
10
24
|
args: 'title',
|
|
11
25
|
|
|
12
26
|
props: {
|
|
13
27
|
delay: Number,
|
|
14
|
-
title: String
|
|
28
|
+
title: String,
|
|
15
29
|
},
|
|
16
30
|
|
|
17
31
|
data: {
|
|
@@ -21,7 +35,7 @@ export default {
|
|
|
21
35
|
animation: ['uk-animation-scale-up'],
|
|
22
36
|
duration: 100,
|
|
23
37
|
cls: 'uk-active',
|
|
24
|
-
clsPos: 'uk-tooltip'
|
|
38
|
+
clsPos: 'uk-tooltip',
|
|
25
39
|
},
|
|
26
40
|
|
|
27
41
|
beforeConnect() {
|
|
@@ -37,25 +51,27 @@ export default {
|
|
|
37
51
|
},
|
|
38
52
|
|
|
39
53
|
methods: {
|
|
40
|
-
|
|
41
54
|
show() {
|
|
42
|
-
|
|
43
55
|
if (this.isToggled(this.tooltip || null) || !this.title) {
|
|
44
56
|
return;
|
|
45
57
|
}
|
|
46
58
|
|
|
47
|
-
this._unbind = once(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
this._unbind = once(
|
|
60
|
+
document,
|
|
61
|
+
`show keydown ${pointerDown}`,
|
|
62
|
+
this.hide,
|
|
63
|
+
false,
|
|
64
|
+
(e) =>
|
|
65
|
+
(e.type === pointerDown && !within(e.target, this.$el)) ||
|
|
66
|
+
(e.type === 'keydown' && e.keyCode === 27) ||
|
|
67
|
+
(e.type === 'show' && e.detail[0] !== this && e.detail[0].$name === this.$name)
|
|
51
68
|
);
|
|
52
69
|
|
|
53
70
|
clearTimeout(this.showTimer);
|
|
54
71
|
this.showTimer = setTimeout(this._show, this.delay);
|
|
55
72
|
},
|
|
56
73
|
|
|
57
|
-
hide() {
|
|
58
|
-
|
|
74
|
+
async hide() {
|
|
59
75
|
if (matches(this.$el, 'input:focus')) {
|
|
60
76
|
return;
|
|
61
77
|
}
|
|
@@ -66,23 +82,21 @@ export default {
|
|
|
66
82
|
return;
|
|
67
83
|
}
|
|
68
84
|
|
|
69
|
-
this.toggleElement(this.tooltip, false, false)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
85
|
+
await this.toggleElement(this.tooltip, false, false);
|
|
86
|
+
remove(this.tooltip);
|
|
87
|
+
this.tooltip = null;
|
|
88
|
+
this._unbind();
|
|
74
89
|
},
|
|
75
90
|
|
|
76
91
|
_show() {
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
this.tooltip = append(
|
|
93
|
+
this.container,
|
|
79
94
|
`<div class="${this.clsPos}">
|
|
80
95
|
<div class="${this.clsPos}-inner">${this.title}</div>
|
|
81
96
|
</div>`
|
|
82
97
|
);
|
|
83
98
|
|
|
84
99
|
on(this.tooltip, 'toggled', (e, toggled) => {
|
|
85
|
-
|
|
86
100
|
this.updateAria(toggled);
|
|
87
101
|
|
|
88
102
|
if (!toggled) {
|
|
@@ -91,23 +105,21 @@ export default {
|
|
|
91
105
|
|
|
92
106
|
this.positionAt(this.tooltip, this.$el);
|
|
93
107
|
|
|
94
|
-
this.origin =
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
this.origin =
|
|
109
|
+
this.getAxis() === 'y'
|
|
110
|
+
? `${flipPosition(this.dir)}-${this.align}`
|
|
111
|
+
: `${this.align}-${flipPosition(this.dir)}`;
|
|
97
112
|
});
|
|
98
113
|
|
|
99
114
|
this.toggleElement(this.tooltip, true);
|
|
100
|
-
|
|
101
115
|
},
|
|
102
116
|
|
|
103
117
|
updateAria(toggled) {
|
|
104
118
|
attr(this.$el, 'aria-expanded', toggled);
|
|
105
|
-
}
|
|
106
|
-
|
|
119
|
+
},
|
|
107
120
|
},
|
|
108
121
|
|
|
109
122
|
events: {
|
|
110
|
-
|
|
111
123
|
focus: 'show',
|
|
112
124
|
blur: 'hide',
|
|
113
125
|
|
|
@@ -123,10 +135,8 @@ export default {
|
|
|
123
135
|
if (isTouch(e)) {
|
|
124
136
|
this.show();
|
|
125
137
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
138
|
+
},
|
|
139
|
+
},
|
|
130
140
|
};
|
|
131
141
|
|
|
132
142
|
function makeFocusable(el) {
|