uikit 3.14.4-dev.871ba3c05 → 3.14.4-dev.8a8016a73
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/CHANGELOG.md +45 -11
- package/build/util.js +1 -0
- package/dist/css/uikit-core-rtl.css +385 -110
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +385 -110
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +402 -115
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +402 -115
- package/dist/css/uikit.min.css +1 -1
- package/dist/js/components/countdown.js +1 -1
- package/dist/js/components/countdown.min.js +1 -1
- package/dist/js/components/filter.js +7 -5
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +185 -137
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +185 -137
- package/dist/js/components/lightbox.min.js +1 -1
- package/dist/js/components/notification.js +1 -1
- package/dist/js/components/notification.min.js +1 -1
- package/dist/js/components/parallax.js +4 -5
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +4 -5
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +22 -7
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +4 -5
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +22 -7
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +3 -3
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +97 -135
- package/dist/js/components/tooltip.min.js +1 -1
- package/dist/js/components/upload.js +1 -1
- package/dist/js/components/upload.min.js +1 -1
- package/dist/js/uikit-core.js +1801 -1709
- package/dist/js/uikit-core.min.js +14 -1
- package/dist/js/uikit-icons.js +1 -1
- package/dist/js/uikit-icons.min.js +1 -1
- package/dist/js/uikit.js +1049 -940
- package/dist/js/uikit.min.js +14 -1
- package/package.json +1 -1
- package/src/images/{backgrounds/nav-parent-open.svg → components/nav-parent-icon-large.svg} +0 -0
- package/src/images/components/nav-parent-icon.svg +3 -0
- package/src/images/components/navbar-parent-icon.svg +3 -0
- package/src/images/components/navbar-toggle-icon.svg +22 -3
- package/src/js/api/state.js +2 -2
- package/src/js/components/filter.js +5 -3
- package/src/js/components/sortable.js +2 -3
- package/src/js/core/accordion.js +9 -17
- package/src/js/core/alert.js +35 -14
- package/src/js/core/drop.js +95 -61
- package/src/js/core/height-viewport.js +14 -6
- package/src/js/core/icon.js +16 -0
- package/src/js/core/index.js +2 -0
- package/src/js/core/leader.js +2 -2
- package/src/js/core/navbar.js +42 -30
- package/src/js/core/offcanvas.js +1 -47
- package/src/js/core/scroll.js +37 -10
- package/src/js/core/sticky.js +8 -9
- package/src/js/core/toggle.js +3 -5
- package/src/js/mixin/media.js +4 -5
- package/src/js/mixin/modal.js +97 -8
- package/src/js/mixin/position.js +26 -11
- package/src/js/mixin/slider-drag.js +20 -8
- package/src/js/mixin/style.js +11 -0
- package/src/js/mixin/togglable.js +80 -133
- package/src/js/util/animation.js +4 -3
- package/src/js/util/dimensions.js +6 -6
- package/src/js/util/filter.js +3 -7
- package/src/js/util/position.js +108 -107
- package/src/js/util/style.js +4 -13
- package/src/js/util/viewport.js +5 -32
- package/src/less/components/_import.less +1 -0
- package/src/less/components/drop.less +1 -18
- package/src/less/components/dropbar.less +115 -0
- package/src/less/components/dropdown.less +16 -16
- package/src/less/components/leader.less +1 -1
- package/src/less/components/nav.less +240 -63
- package/src/less/components/navbar.less +81 -38
- package/src/less/components/utility.less +21 -4
- package/src/less/theme/_import.less +1 -0
- package/src/less/theme/dropbar.less +44 -0
- package/src/less/theme/dropdown.less +0 -11
- package/src/less/theme/nav.less +43 -9
- package/src/less/theme/navbar.less +7 -11
- package/src/scss/components/_import.scss +1 -0
- package/src/scss/components/drop.scss +1 -18
- package/src/scss/components/dropbar.scss +115 -0
- package/src/scss/components/dropdown.scss +16 -16
- package/src/scss/components/leader.scss +1 -1
- package/src/scss/components/nav.scss +189 -51
- package/src/scss/components/navbar.scss +69 -38
- package/src/scss/components/utility.scss +19 -3
- package/src/scss/mixins-theme.scss +93 -25
- package/src/scss/mixins.scss +89 -17
- package/src/scss/theme/_import.scss +1 -0
- package/src/scss/theme/dropbar.scss +44 -0
- package/src/scss/theme/dropdown.scss +0 -8
- package/src/scss/theme/nav.scss +41 -9
- package/src/scss/theme/navbar.scss +7 -8
- package/src/scss/variables-theme.scss +71 -18
- package/src/scss/variables.scss +60 -14
- package/tests/accordion.html +2 -2
- package/tests/alert.html +2 -2
- package/tests/countdown.html +1 -1
- package/tests/drop.html +457 -371
- package/tests/dropbar.html +456 -0
- package/tests/dropdown.html +26 -401
- package/tests/filter.html +9 -12
- package/tests/form.html +1 -1
- package/tests/index.html +126 -107
- package/tests/js/index.js +1 -4
- package/tests/lightbox.html +5 -5
- package/tests/list.html +8 -8
- package/tests/modal.html +13 -13
- package/tests/nav.html +117 -75
- package/tests/navbar.html +1998 -1139
- package/tests/offcanvas.html +17 -21
- package/tests/parallax.html +1 -1
- package/tests/position.html +18 -16
- package/tests/progress.html +9 -9
- package/tests/scroll.html +7 -10
- package/tests/search.html +5 -5
- package/tests/slider.html +6 -5
- package/tests/slideshow.html +8 -8
- package/tests/sortable.html +6 -8
- package/tests/sticky-navbar.html +6 -6
- package/tests/sticky.html +8 -8
- package/tests/switcher.html +1 -1
- package/tests/tab.html +1 -1
- package/tests/table.html +7 -7
- package/tests/toggle.html +2 -2
- package/tests/tooltip.html +1 -1
- package/tests/upload.html +11 -11
- package/tests/utility.html +19 -0
- package/src/images/backgrounds/nav-parent-close.svg +0 -3
package/src/js/core/navbar.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
offset,
|
|
20
20
|
once,
|
|
21
21
|
parent,
|
|
22
|
+
parents,
|
|
22
23
|
query,
|
|
23
24
|
remove,
|
|
24
25
|
selFocusable,
|
|
@@ -36,7 +37,7 @@ export default {
|
|
|
36
37
|
align: String,
|
|
37
38
|
offset: Number,
|
|
38
39
|
boundary: Boolean,
|
|
39
|
-
|
|
40
|
+
target: Boolean,
|
|
40
41
|
clsDrop: String,
|
|
41
42
|
delayShow: Number,
|
|
42
43
|
delayHide: Number,
|
|
@@ -53,9 +54,12 @@ export default {
|
|
|
53
54
|
offset: undefined,
|
|
54
55
|
delayShow: undefined,
|
|
55
56
|
delayHide: undefined,
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
flip: false,
|
|
58
|
+
shift: true,
|
|
58
59
|
boundary: true,
|
|
60
|
+
target: false,
|
|
61
|
+
targetX: false,
|
|
62
|
+
targetY: false,
|
|
59
63
|
dropbar: false,
|
|
60
64
|
dropbarAnchor: false,
|
|
61
65
|
duration: 200,
|
|
@@ -90,7 +94,7 @@ export default {
|
|
|
90
94
|
},
|
|
91
95
|
|
|
92
96
|
watch(dropbar) {
|
|
93
|
-
addClass(dropbar, 'uk-navbar-dropbar');
|
|
97
|
+
addClass(dropbar, 'uk-dropbar', 'uk-dropbar-top', 'uk-navbar-dropbar');
|
|
94
98
|
},
|
|
95
99
|
|
|
96
100
|
immediate: true,
|
|
@@ -106,7 +110,7 @@ export default {
|
|
|
106
110
|
|
|
107
111
|
if (this.dropContainer !== $el) {
|
|
108
112
|
for (const el of $$(`.${clsDrop}`, this.dropContainer)) {
|
|
109
|
-
const target = this.getDropdown(el)?.
|
|
113
|
+
const target = this.getDropdown(el)?.targetEl;
|
|
110
114
|
if (!includes(dropdowns, el) && target && within(target, this.$el)) {
|
|
111
115
|
dropdowns.push(el);
|
|
112
116
|
}
|
|
@@ -124,7 +128,6 @@ export default {
|
|
|
124
128
|
...this.$props,
|
|
125
129
|
boundary: this.boundary,
|
|
126
130
|
pos: this.pos,
|
|
127
|
-
offset: this.dropbar || this.offset,
|
|
128
131
|
}
|
|
129
132
|
);
|
|
130
133
|
},
|
|
@@ -169,8 +172,8 @@ export default {
|
|
|
169
172
|
if (
|
|
170
173
|
active &&
|
|
171
174
|
includes(active.mode, 'hover') &&
|
|
172
|
-
active.
|
|
173
|
-
!within(active.
|
|
175
|
+
active.targetEl &&
|
|
176
|
+
!within(active.targetEl, current) &&
|
|
174
177
|
!active.isDelaying
|
|
175
178
|
) {
|
|
176
179
|
active.hide(false);
|
|
@@ -192,7 +195,7 @@ export default {
|
|
|
192
195
|
if (keyCode === keyMap.DOWN && hasAttr(current, 'aria-expanded')) {
|
|
193
196
|
e.preventDefault();
|
|
194
197
|
|
|
195
|
-
if (!active || active.
|
|
198
|
+
if (!active || active.targetEl !== current) {
|
|
196
199
|
current.click();
|
|
197
200
|
once(this.dropContainer, 'show', ({ target }) =>
|
|
198
201
|
focusFirstFocusableElement(target)
|
|
@@ -243,7 +246,7 @@ export default {
|
|
|
243
246
|
}
|
|
244
247
|
|
|
245
248
|
if (keyCode === keyMap.ESC) {
|
|
246
|
-
active?.
|
|
249
|
+
active?.targetEl?.focus();
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
handleNavItemNavigation(e, this.toggles, active);
|
|
@@ -285,8 +288,8 @@ export default {
|
|
|
285
288
|
return this.dropbar;
|
|
286
289
|
},
|
|
287
290
|
|
|
288
|
-
handler(
|
|
289
|
-
if (!
|
|
291
|
+
handler({ target }) {
|
|
292
|
+
if (!this.isDropbarDrop(target)) {
|
|
290
293
|
return;
|
|
291
294
|
}
|
|
292
295
|
|
|
@@ -294,7 +297,7 @@ export default {
|
|
|
294
297
|
after(this.dropbarAnchor || this.$el, this.dropbar);
|
|
295
298
|
}
|
|
296
299
|
|
|
297
|
-
addClass(
|
|
300
|
+
addClass(target, `${this.clsDrop}-dropbar`);
|
|
298
301
|
},
|
|
299
302
|
},
|
|
300
303
|
|
|
@@ -309,19 +312,24 @@ export default {
|
|
|
309
312
|
return this.dropbar;
|
|
310
313
|
},
|
|
311
314
|
|
|
312
|
-
handler(
|
|
313
|
-
if (!
|
|
315
|
+
handler({ target }) {
|
|
316
|
+
if (!this.isDropbarDrop(target)) {
|
|
314
317
|
return;
|
|
315
318
|
}
|
|
316
319
|
|
|
317
|
-
this._observer = observeResize(
|
|
320
|
+
this._observer = observeResize(target, () => {
|
|
321
|
+
const targetOffsets = parents(target, `.${this.clsDrop}`)
|
|
322
|
+
.concat(target)
|
|
323
|
+
.map((el) => offset(el));
|
|
324
|
+
const minTop = Math.min(...targetOffsets.map(({ top }) => top));
|
|
325
|
+
const maxBottom = Math.max(...targetOffsets.map(({ bottom }) => bottom));
|
|
326
|
+
const dropbarOffset = offset(this.dropbar);
|
|
327
|
+
css(this.dropbar, 'top', this.dropbar.offsetTop - (dropbarOffset.top - minTop));
|
|
318
328
|
this.transitionTo(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
)
|
|
324
|
-
);
|
|
329
|
+
maxBottom - minTop + toFloat(css(target, 'marginBottom')),
|
|
330
|
+
target
|
|
331
|
+
);
|
|
332
|
+
});
|
|
325
333
|
},
|
|
326
334
|
},
|
|
327
335
|
|
|
@@ -336,13 +344,13 @@ export default {
|
|
|
336
344
|
return this.dropbar;
|
|
337
345
|
},
|
|
338
346
|
|
|
339
|
-
handler(e
|
|
347
|
+
handler(e) {
|
|
340
348
|
const active = this.getActive();
|
|
341
349
|
|
|
342
350
|
if (
|
|
343
351
|
matches(this.dropbar, ':hover') &&
|
|
344
|
-
active?.$el ===
|
|
345
|
-
!this.toggles.some((el) => active.
|
|
352
|
+
active?.$el === e.target &&
|
|
353
|
+
!this.toggles.some((el) => active.targetEl !== el && matches(el, ':focus'))
|
|
346
354
|
) {
|
|
347
355
|
e.preventDefault();
|
|
348
356
|
}
|
|
@@ -360,8 +368,8 @@ export default {
|
|
|
360
368
|
return this.dropbar;
|
|
361
369
|
},
|
|
362
370
|
|
|
363
|
-
handler(
|
|
364
|
-
if (!
|
|
371
|
+
handler({ target }) {
|
|
372
|
+
if (!this.isDropbarDrop(target)) {
|
|
365
373
|
return;
|
|
366
374
|
}
|
|
367
375
|
|
|
@@ -369,7 +377,7 @@ export default {
|
|
|
369
377
|
|
|
370
378
|
const active = this.getActive();
|
|
371
379
|
|
|
372
|
-
if (!active || active?.$el ===
|
|
380
|
+
if (!active || active?.$el === target) {
|
|
373
381
|
this.transitionTo(0);
|
|
374
382
|
}
|
|
375
383
|
},
|
|
@@ -378,7 +386,7 @@ export default {
|
|
|
378
386
|
|
|
379
387
|
methods: {
|
|
380
388
|
getActive() {
|
|
381
|
-
return active && within(active.
|
|
389
|
+
return active && within(active.targetEl, this.$el) && active;
|
|
382
390
|
},
|
|
383
391
|
|
|
384
392
|
transitionTo(newHeight, el) {
|
|
@@ -409,12 +417,16 @@ export default {
|
|
|
409
417
|
getDropdown(el) {
|
|
410
418
|
return this.$getComponent(el, 'drop') || this.$getComponent(el, 'dropdown');
|
|
411
419
|
},
|
|
420
|
+
|
|
421
|
+
isDropbarDrop(el) {
|
|
422
|
+
return this.getDropdown(el) && hasClass(el, this.clsDrop);
|
|
423
|
+
},
|
|
412
424
|
},
|
|
413
425
|
};
|
|
414
426
|
|
|
415
427
|
function handleNavItemNavigation(e, toggles, active) {
|
|
416
428
|
const { current, keyCode } = e;
|
|
417
|
-
const target = active?.
|
|
429
|
+
const target = active?.targetEl || current;
|
|
418
430
|
const i = toggles.indexOf(target);
|
|
419
431
|
|
|
420
432
|
// Left
|
package/src/js/core/offcanvas.js
CHANGED
|
@@ -93,22 +93,6 @@ export default {
|
|
|
93
93
|
},
|
|
94
94
|
},
|
|
95
95
|
|
|
96
|
-
{
|
|
97
|
-
name: 'touchstart',
|
|
98
|
-
|
|
99
|
-
passive: true,
|
|
100
|
-
|
|
101
|
-
el() {
|
|
102
|
-
return this.panel;
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
handler({ targetTouches }) {
|
|
106
|
-
if (targetTouches.length === 1) {
|
|
107
|
-
this.clientY = targetTouches[0].clientY;
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
|
|
112
96
|
{
|
|
113
97
|
name: 'touchmove',
|
|
114
98
|
|
|
@@ -124,33 +108,6 @@ export default {
|
|
|
124
108
|
},
|
|
125
109
|
},
|
|
126
110
|
|
|
127
|
-
{
|
|
128
|
-
name: 'touchmove',
|
|
129
|
-
|
|
130
|
-
passive: false,
|
|
131
|
-
|
|
132
|
-
el() {
|
|
133
|
-
return this.panel;
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
handler(e) {
|
|
137
|
-
if (e.targetTouches.length !== 1) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const clientY = e.targetTouches[0].clientY - this.clientY;
|
|
142
|
-
const { scrollTop, scrollHeight, clientHeight } = this.panel;
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
clientHeight >= scrollHeight ||
|
|
146
|
-
(scrollTop === 0 && clientY > 0) ||
|
|
147
|
-
(scrollHeight - scrollTop <= clientHeight && clientY < 0)
|
|
148
|
-
) {
|
|
149
|
-
e.cancelable && e.preventDefault();
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
|
|
154
111
|
{
|
|
155
112
|
name: 'show',
|
|
156
113
|
|
|
@@ -162,7 +119,6 @@ export default {
|
|
|
162
119
|
addClass(parent(this.panel), this.clsMode);
|
|
163
120
|
}
|
|
164
121
|
|
|
165
|
-
css(document.documentElement, 'overflowY', this.overlay ? 'hidden' : '');
|
|
166
122
|
addClass(document.body, this.clsContainer, this.clsFlip);
|
|
167
123
|
css(document.body, 'touch-action', 'pan-y pinch-zoom');
|
|
168
124
|
css(this.$el, 'display', 'block');
|
|
@@ -170,7 +126,7 @@ export default {
|
|
|
170
126
|
addClass(
|
|
171
127
|
this.panel,
|
|
172
128
|
this.clsSidebarAnimation,
|
|
173
|
-
this.mode
|
|
129
|
+
this.mode === 'reveal' ? '' : this.clsMode
|
|
174
130
|
);
|
|
175
131
|
|
|
176
132
|
height(document.body); // force reflow
|
|
@@ -207,8 +163,6 @@ export default {
|
|
|
207
163
|
removeClass(this.$el, this.clsOverlay);
|
|
208
164
|
css(this.$el, 'display', '');
|
|
209
165
|
removeClass(document.body, this.clsContainer, this.clsFlip);
|
|
210
|
-
|
|
211
|
-
css(document.documentElement, 'overflowY', '');
|
|
212
166
|
},
|
|
213
167
|
},
|
|
214
168
|
|
package/src/js/core/scroll.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $, scrollIntoView, trigger } from 'uikit-util';
|
|
1
|
+
import { $, off, on, scrollIntoView, trigger, within } from 'uikit-util';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
props: {
|
|
@@ -9,6 +9,14 @@ export default {
|
|
|
9
9
|
offset: 0,
|
|
10
10
|
},
|
|
11
11
|
|
|
12
|
+
connected() {
|
|
13
|
+
registerClick(this);
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
disconnected() {
|
|
17
|
+
unregisterClick(this);
|
|
18
|
+
},
|
|
19
|
+
|
|
12
20
|
methods: {
|
|
13
21
|
async scrollTo(el) {
|
|
14
22
|
el = (el && $(el)) || document.body;
|
|
@@ -19,18 +27,37 @@ export default {
|
|
|
19
27
|
}
|
|
20
28
|
},
|
|
21
29
|
},
|
|
30
|
+
};
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
const components = new Set();
|
|
33
|
+
function registerClick(cmp) {
|
|
34
|
+
if (!components.size) {
|
|
35
|
+
on(document, 'click', clickHandler);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
components.add(cmp);
|
|
39
|
+
}
|
|
28
40
|
|
|
41
|
+
function unregisterClick(cmp) {
|
|
42
|
+
components.delete(cmp);
|
|
43
|
+
|
|
44
|
+
if (!components.length) {
|
|
45
|
+
off(document, 'click', clickHandler);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function clickHandler(e) {
|
|
50
|
+
if (e.defaultPrevented) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const component of components) {
|
|
55
|
+
if (within(e.target, component.$el)) {
|
|
29
56
|
e.preventDefault();
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
57
|
+
component.scrollTo(getTargetElement(component.$el));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
34
61
|
|
|
35
62
|
export function getTargetElement(el) {
|
|
36
63
|
return document.getElementById(decodeURIComponent(el.hash).substring(1));
|
package/src/js/core/sticky.js
CHANGED
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
remove,
|
|
24
24
|
removeClass,
|
|
25
25
|
replaceClass,
|
|
26
|
-
scrollTop,
|
|
27
26
|
toFloat,
|
|
28
27
|
toggleClass,
|
|
29
28
|
toPx,
|
|
@@ -125,7 +124,9 @@ export default {
|
|
|
125
124
|
},
|
|
126
125
|
|
|
127
126
|
handler() {
|
|
128
|
-
|
|
127
|
+
const { scrollingElement } = document;
|
|
128
|
+
|
|
129
|
+
if (!location.hash || scrollingElement.scrollTop === 0) {
|
|
129
130
|
return;
|
|
130
131
|
}
|
|
131
132
|
|
|
@@ -134,13 +135,11 @@ export default {
|
|
|
134
135
|
const elOffset = getOffset(this.$el);
|
|
135
136
|
|
|
136
137
|
if (this.isFixed && intersectRect(targetOffset, elOffset)) {
|
|
137
|
-
scrollTop
|
|
138
|
-
window,
|
|
138
|
+
scrollingElement.scrollTop =
|
|
139
139
|
targetOffset.top -
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
);
|
|
140
|
+
elOffset.height -
|
|
141
|
+
toPx(this.targetOffset, 'height', this.placeholder) -
|
|
142
|
+
toPx(this.offset, 'height', this.placeholder);
|
|
144
143
|
}
|
|
145
144
|
});
|
|
146
145
|
},
|
|
@@ -238,7 +237,7 @@ export default {
|
|
|
238
237
|
start,
|
|
239
238
|
end,
|
|
240
239
|
}) {
|
|
241
|
-
const scroll = scrollTop
|
|
240
|
+
const scroll = document.scrollingElement.scrollTop;
|
|
242
241
|
const dir = prevScroll <= scroll ? 'down' : 'up';
|
|
243
242
|
|
|
244
243
|
return {
|
package/src/js/core/toggle.js
CHANGED
|
@@ -181,7 +181,7 @@ export default {
|
|
|
181
181
|
},
|
|
182
182
|
|
|
183
183
|
{
|
|
184
|
-
name: '
|
|
184
|
+
name: 'hide show',
|
|
185
185
|
|
|
186
186
|
self: true,
|
|
187
187
|
|
|
@@ -189,10 +189,8 @@ export default {
|
|
|
189
189
|
return this.target;
|
|
190
190
|
},
|
|
191
191
|
|
|
192
|
-
handler(
|
|
193
|
-
|
|
194
|
-
this.updateAria(toggled);
|
|
195
|
-
}
|
|
192
|
+
handler({ type }) {
|
|
193
|
+
this.updateAria(type === 'show');
|
|
196
194
|
},
|
|
197
195
|
},
|
|
198
196
|
|
package/src/js/mixin/media.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createEvent,
|
|
3
|
-
|
|
3
|
+
css,
|
|
4
4
|
isNumeric,
|
|
5
5
|
isString,
|
|
6
6
|
on,
|
|
@@ -19,7 +19,7 @@ export default {
|
|
|
19
19
|
},
|
|
20
20
|
|
|
21
21
|
connected() {
|
|
22
|
-
const media = toMedia(this.media);
|
|
22
|
+
const media = toMedia(this.media, this.$el);
|
|
23
23
|
this.matchMedia = true;
|
|
24
24
|
if (media) {
|
|
25
25
|
this.mediaObj = window.matchMedia(media);
|
|
@@ -40,11 +40,10 @@ export default {
|
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
function toMedia(value) {
|
|
43
|
+
function toMedia(value, element) {
|
|
44
44
|
if (isString(value)) {
|
|
45
45
|
if (startsWith(value, '@')) {
|
|
46
|
-
|
|
47
|
-
value = toFloat(getCssVar(name));
|
|
46
|
+
value = toFloat(css(element, `--uk-breakpoint-${value.substr(1)}`));
|
|
48
47
|
} else if (isNaN(value)) {
|
|
49
48
|
return value;
|
|
50
49
|
}
|
package/src/js/mixin/modal.js
CHANGED
|
@@ -2,12 +2,14 @@ import {
|
|
|
2
2
|
$,
|
|
3
3
|
addClass,
|
|
4
4
|
append,
|
|
5
|
+
apply,
|
|
5
6
|
attr,
|
|
6
7
|
css,
|
|
7
8
|
endsWith,
|
|
8
9
|
includes,
|
|
9
10
|
isFocusable,
|
|
10
11
|
last,
|
|
12
|
+
noop,
|
|
11
13
|
on,
|
|
12
14
|
once,
|
|
13
15
|
parent,
|
|
@@ -15,6 +17,7 @@ import {
|
|
|
15
17
|
pointerDown,
|
|
16
18
|
pointerUp,
|
|
17
19
|
removeClass,
|
|
20
|
+
scrollParents,
|
|
18
21
|
toFloat,
|
|
19
22
|
width,
|
|
20
23
|
within,
|
|
@@ -121,17 +124,26 @@ export default {
|
|
|
121
124
|
self: true,
|
|
122
125
|
|
|
123
126
|
handler() {
|
|
124
|
-
|
|
127
|
+
once(
|
|
128
|
+
this.$el,
|
|
129
|
+
'hide',
|
|
130
|
+
on(document, 'focusin', (e) => {
|
|
131
|
+
if (last(active) === this && !within(e.target, this.$el)) {
|
|
132
|
+
this.$el.focus();
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
);
|
|
125
136
|
|
|
126
|
-
if (
|
|
127
|
-
|
|
137
|
+
if (this.overlay) {
|
|
138
|
+
once(this.$el, 'hidden', preventOverscroll(this.$el));
|
|
139
|
+
once(this.$el, 'hidden', preventBackgroundScroll());
|
|
128
140
|
}
|
|
129
141
|
|
|
130
142
|
if (this.stack) {
|
|
131
143
|
css(this.$el, 'zIndex', toFloat(css(this.$el, 'zIndex')) + active.length);
|
|
132
144
|
}
|
|
133
145
|
|
|
134
|
-
addClass(
|
|
146
|
+
addClass(document.documentElement, this.clsPage);
|
|
135
147
|
|
|
136
148
|
if (this.bgClose) {
|
|
137
149
|
once(
|
|
@@ -206,10 +218,6 @@ export default {
|
|
|
206
218
|
active.splice(active.indexOf(this), 1);
|
|
207
219
|
}
|
|
208
220
|
|
|
209
|
-
if (!active.length) {
|
|
210
|
-
css(document.body, 'overflowY', '');
|
|
211
|
-
}
|
|
212
|
-
|
|
213
221
|
css(this.$el, 'zIndex', '');
|
|
214
222
|
|
|
215
223
|
if (!active.some((modal) => modal.clsPage === this.clsPage)) {
|
|
@@ -273,3 +281,84 @@ function animate({ transitionElement, _toggle }) {
|
|
|
273
281
|
function toMs(time) {
|
|
274
282
|
return time ? (endsWith(time, 'ms') ? toFloat(time) : toFloat(time) * 1000) : 0;
|
|
275
283
|
}
|
|
284
|
+
|
|
285
|
+
export function preventOverscroll(el) {
|
|
286
|
+
if (CSS.supports('overscroll-behavior', 'contain')) {
|
|
287
|
+
const elements = filterChildren(el, (child) => /auto|scroll/.test(css(child, 'overflow')));
|
|
288
|
+
css(elements, 'overscrollBehavior', 'contain');
|
|
289
|
+
return () => css(elements, 'overscrollBehavior', '');
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
let startClientY;
|
|
293
|
+
|
|
294
|
+
const events = [
|
|
295
|
+
on(
|
|
296
|
+
el,
|
|
297
|
+
'touchstart',
|
|
298
|
+
({ targetTouches }) => {
|
|
299
|
+
if (targetTouches.length === 1) {
|
|
300
|
+
startClientY = targetTouches[0].clientY;
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
{ passive: true }
|
|
304
|
+
),
|
|
305
|
+
|
|
306
|
+
on(
|
|
307
|
+
el,
|
|
308
|
+
'touchmove',
|
|
309
|
+
(e) => {
|
|
310
|
+
if (e.targetTouches.length !== 1) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
let [scrollParent] = scrollParents(e.target, /auto|scroll/);
|
|
315
|
+
if (!within(scrollParent, el)) {
|
|
316
|
+
scrollParent = el;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const clientY = e.targetTouches[0].clientY - startClientY;
|
|
320
|
+
const { scrollTop, scrollHeight, clientHeight } = scrollParent;
|
|
321
|
+
|
|
322
|
+
if (
|
|
323
|
+
clientHeight >= scrollHeight ||
|
|
324
|
+
(scrollTop === 0 && clientY > 0) ||
|
|
325
|
+
(scrollHeight - scrollTop <= clientHeight && clientY < 0)
|
|
326
|
+
) {
|
|
327
|
+
e.cancelable && e.preventDefault();
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{ passive: false }
|
|
331
|
+
),
|
|
332
|
+
];
|
|
333
|
+
|
|
334
|
+
return () => events.forEach((fn) => fn());
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
let prevented;
|
|
338
|
+
export function preventBackgroundScroll() {
|
|
339
|
+
if (prevented) {
|
|
340
|
+
return noop;
|
|
341
|
+
}
|
|
342
|
+
prevented = true;
|
|
343
|
+
const { body, documentElement } = document;
|
|
344
|
+
css(body, {
|
|
345
|
+
overflowY: width(window) > documentElement.clientWidth ? 'scroll' : '',
|
|
346
|
+
touchAction: 'none',
|
|
347
|
+
});
|
|
348
|
+
css(documentElement, 'overflowY', 'hidden');
|
|
349
|
+
return () => {
|
|
350
|
+
prevented = false;
|
|
351
|
+
css(documentElement, 'overflowY', '');
|
|
352
|
+
css(body, { overflowY: '', touchAction: '' });
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function filterChildren(el, fn) {
|
|
357
|
+
const children = [];
|
|
358
|
+
apply(el, (node) => {
|
|
359
|
+
if (fn(node)) {
|
|
360
|
+
children.push(node);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
return children;
|
|
364
|
+
}
|