uikit 3.16.4-dev.fd2458e3b → 3.16.5-dev.dda1f1b31
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 +1 -0
- package/CHANGELOG.md +9 -1
- package/build/build.js +5 -4
- package/build/icons.js +2 -1
- package/build/less.js +2 -11
- package/build/prefix.js +2 -1
- package/build/release.js +4 -3
- package/build/scope.js +2 -1
- package/build/scss.js +2 -1
- package/build/util.js +3 -3
- package/dist/css/uikit-core-rtl.css +1 -1
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +1 -1
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +1 -1
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +1 -1
- package/dist/css/uikit.min.css +1 -1
- package/dist/js/components/countdown.js +12 -14
- package/dist/js/components/countdown.min.js +1 -1
- package/dist/js/components/filter.js +506 -22
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +2601 -310
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +2612 -323
- 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 +466 -43
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +184 -2
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +2345 -49
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +184 -2
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +2339 -49
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +472 -1
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +2298 -11
- 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 +951 -931
- package/dist/js/uikit-core.min.js +1 -1
- package/dist/js/uikit-icons.js +153 -152
- package/dist/js/uikit-icons.min.js +1 -1
- package/dist/js/uikit.js +979 -954
- package/dist/js/uikit.min.js +1 -1
- package/package.json +2 -2
- package/src/images/icons/mastodon.svg +3 -0
- package/src/js/api/app.js +12 -0
- package/src/js/api/boot.js +64 -43
- package/src/js/api/component.js +60 -61
- package/src/js/api/computed.js +39 -0
- package/src/js/api/events.js +45 -0
- package/src/js/api/global.js +58 -56
- package/src/js/api/hooks.js +35 -114
- package/src/js/api/index.js +8 -24
- package/src/js/api/instance.js +55 -55
- package/src/js/api/log.js +10 -0
- package/src/js/api/observables.js +125 -0
- package/src/js/api/observer.js +76 -0
- package/src/js/{util → api}/options.js +38 -1
- package/src/js/api/props.js +102 -0
- package/src/js/api/state.js +26 -280
- package/src/js/api/update.js +77 -0
- package/src/js/api/watch.js +34 -0
- package/src/js/components/countdown.js +14 -16
- package/src/js/components/filter.js +18 -24
- package/src/js/components/internal/slider-preload.js +5 -6
- package/src/js/components/lightbox-panel.js +1 -1
- package/src/js/components/lightbox.js +11 -23
- package/src/js/components/parallax.js +8 -6
- package/src/js/components/slider.js +10 -0
- package/src/js/components/tooltip.js +2 -1
- package/src/js/core/accordion.js +5 -6
- package/src/js/core/cover.js +9 -9
- package/src/js/core/drop.js +13 -6
- package/src/js/core/dropnav.js +1 -1
- package/src/js/core/grid.js +2 -5
- package/src/js/core/height-match.js +9 -16
- package/src/js/core/height-viewport.js +5 -7
- package/src/js/core/img.js +12 -19
- package/src/js/core/leader.js +4 -2
- package/src/js/core/margin.js +11 -21
- package/src/js/core/modal.js +1 -1
- package/src/js/core/offcanvas.js +6 -2
- package/src/js/core/overflow-auto.js +5 -5
- package/src/js/core/responsive.js +5 -7
- package/src/js/core/scroll.js +19 -10
- package/src/js/core/scrollspy-nav.js +6 -5
- package/src/js/core/scrollspy.js +27 -36
- package/src/js/core/sticky.js +12 -10
- package/src/js/core/svg.js +4 -2
- package/src/js/core/switcher.js +11 -9
- package/src/js/core/toggle.js +4 -4
- package/src/js/core/video.js +6 -14
- package/src/js/mixin/modal.js +2 -1
- package/src/js/mixin/parallax.js +1 -1
- package/src/js/mixin/slider-nav.js +2 -1
- package/src/js/mixin/slider.js +9 -3
- package/src/js/util/filter.js +13 -0
- package/src/js/util/index.js +0 -1
- package/src/js/util/keys.js +11 -0
- package/src/js/util/lang.js +7 -7
- package/src/js/util/observer.js +4 -2
- package/src/js/util/scroll.js +42 -0
- package/src/js/util/svg.js +16 -0
- package/src/js/util/viewport.js +1 -1
- package/src/scss/mixins-theme.scss +1640 -1596
- package/src/scss/mixins.scss +1370 -1370
- package/src/scss/variables-theme.scss +1255 -1255
- package/src/scss/variables.scss +1113 -1113
- package/src/js/mixin/lazyload.js +0 -27
- package/src/js/mixin/resize.js +0 -11
- package/src/js/mixin/scroll.js +0 -32
- package/src/js/mixin/swipe.js +0 -72
- package/src/js/mixin/utils.js +0 -91
package/src/js/core/scrollspy.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { intersection } from '../api/observables';
|
|
2
2
|
import {
|
|
3
3
|
$$,
|
|
4
4
|
css,
|
|
5
5
|
filter,
|
|
6
6
|
data as getData,
|
|
7
|
-
isEqual,
|
|
8
|
-
observeIntersection,
|
|
9
7
|
once,
|
|
10
8
|
removeClass,
|
|
11
9
|
removeClasses,
|
|
@@ -14,8 +12,6 @@ import {
|
|
|
14
12
|
} from 'uikit-util';
|
|
15
13
|
|
|
16
14
|
export default {
|
|
17
|
-
mixins: [Scroll],
|
|
18
|
-
|
|
19
15
|
args: 'cls',
|
|
20
16
|
|
|
21
17
|
props: {
|
|
@@ -43,15 +39,11 @@ export default {
|
|
|
43
39
|
return target ? $$(target, $el) : [$el];
|
|
44
40
|
},
|
|
45
41
|
|
|
46
|
-
watch(elements
|
|
42
|
+
watch(elements) {
|
|
47
43
|
if (this.hidden) {
|
|
48
44
|
// use `opacity:0` instead of `visibility:hidden` to make content focusable with keyboard
|
|
49
45
|
css(filter(elements, `:not(.${this.inViewClass})`), 'opacity', 0);
|
|
50
46
|
}
|
|
51
|
-
|
|
52
|
-
if (!isEqual(elements, prev)) {
|
|
53
|
-
this.$reset();
|
|
54
|
-
}
|
|
55
47
|
},
|
|
56
48
|
|
|
57
49
|
immediate: true,
|
|
@@ -60,32 +52,6 @@ export default {
|
|
|
60
52
|
|
|
61
53
|
connected() {
|
|
62
54
|
this._data.elements = new Map();
|
|
63
|
-
this.registerObserver(
|
|
64
|
-
observeIntersection(
|
|
65
|
-
this.elements,
|
|
66
|
-
(records) => {
|
|
67
|
-
const elements = this._data.elements;
|
|
68
|
-
for (const { target: el, isIntersecting } of records) {
|
|
69
|
-
if (!elements.has(el)) {
|
|
70
|
-
elements.set(el, {
|
|
71
|
-
cls: getData(el, 'uk-scrollspy-class') || this.cls,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const state = elements.get(el);
|
|
76
|
-
if (!this.repeat && state.show) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
state.show = isIntersecting;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
this.$emit();
|
|
84
|
-
},
|
|
85
|
-
{ rootMargin: this.margin },
|
|
86
|
-
false
|
|
87
|
-
)
|
|
88
|
-
);
|
|
89
55
|
},
|
|
90
56
|
|
|
91
57
|
disconnected() {
|
|
@@ -94,6 +60,31 @@ export default {
|
|
|
94
60
|
}
|
|
95
61
|
},
|
|
96
62
|
|
|
63
|
+
observe: intersection({
|
|
64
|
+
target: ({ elements }) => elements,
|
|
65
|
+
handler(records) {
|
|
66
|
+
const elements = this._data.elements;
|
|
67
|
+
for (const { target: el, isIntersecting } of records) {
|
|
68
|
+
if (!elements.has(el)) {
|
|
69
|
+
elements.set(el, {
|
|
70
|
+
cls: getData(el, 'uk-scrollspy-class') || this.cls,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const state = elements.get(el);
|
|
75
|
+
if (!this.repeat && state.show) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
state.show = isIntersecting;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.$emit();
|
|
83
|
+
},
|
|
84
|
+
options: (instance) => ({ rootMargin: instance.margin }),
|
|
85
|
+
args: { intersecting: false },
|
|
86
|
+
}),
|
|
87
|
+
|
|
97
88
|
update: [
|
|
98
89
|
{
|
|
99
90
|
write(data) {
|
package/src/js/core/sticky.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Class from '../mixin/class';
|
|
2
2
|
import Media from '../mixin/media';
|
|
3
|
-
import
|
|
4
|
-
import Scroll from '../mixin/scroll';
|
|
3
|
+
import { resize, scroll } from '../api/observables';
|
|
5
4
|
import {
|
|
6
5
|
$,
|
|
7
6
|
addClass,
|
|
@@ -17,7 +16,6 @@ import {
|
|
|
17
16
|
isString,
|
|
18
17
|
isVisible,
|
|
19
18
|
noop,
|
|
20
|
-
observeResize,
|
|
21
19
|
offsetPosition,
|
|
22
20
|
parent,
|
|
23
21
|
query,
|
|
@@ -32,7 +30,7 @@ import {
|
|
|
32
30
|
} from 'uikit-util';
|
|
33
31
|
|
|
34
32
|
export default {
|
|
35
|
-
mixins: [Class, Media
|
|
33
|
+
mixins: [Class, Media],
|
|
36
34
|
|
|
37
35
|
props: {
|
|
38
36
|
position: String,
|
|
@@ -76,10 +74,6 @@ export default {
|
|
|
76
74
|
},
|
|
77
75
|
},
|
|
78
76
|
|
|
79
|
-
resizeTargets() {
|
|
80
|
-
return document.documentElement;
|
|
81
|
-
},
|
|
82
|
-
|
|
83
77
|
connected() {
|
|
84
78
|
this.start = coerce(this.start || this.top);
|
|
85
79
|
this.end = coerce(this.end || this.bottom);
|
|
@@ -89,8 +83,6 @@ export default {
|
|
|
89
83
|
$('<div class="uk-sticky-placeholder"></div>');
|
|
90
84
|
this.isFixed = false;
|
|
91
85
|
this.setActive(false);
|
|
92
|
-
|
|
93
|
-
this.registerObserver(observeResize(this.$el, () => !this.isFixed && this.$emit('resize')));
|
|
94
86
|
},
|
|
95
87
|
|
|
96
88
|
disconnected() {
|
|
@@ -104,6 +96,16 @@ export default {
|
|
|
104
96
|
this.placeholder = null;
|
|
105
97
|
},
|
|
106
98
|
|
|
99
|
+
observe: [
|
|
100
|
+
resize({
|
|
101
|
+
handler() {
|
|
102
|
+
!this.isFixed && this.$emit('resize');
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
resize({ target: () => [document.documentElement] }),
|
|
106
|
+
scroll(),
|
|
107
|
+
],
|
|
108
|
+
|
|
107
109
|
events: [
|
|
108
110
|
{
|
|
109
111
|
name: 'resize',
|
package/src/js/core/svg.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { registerObserver } from '../api/observer';
|
|
2
|
+
import { getMaxPathLength } from '../util/svg';
|
|
1
3
|
import {
|
|
2
4
|
$,
|
|
3
5
|
after,
|
|
@@ -15,7 +17,6 @@ import {
|
|
|
15
17
|
startsWith,
|
|
16
18
|
toFloat,
|
|
17
19
|
} from 'uikit-util';
|
|
18
|
-
import { getMaxPathLength } from '../mixin/utils';
|
|
19
20
|
|
|
20
21
|
export default {
|
|
21
22
|
args: 'src',
|
|
@@ -67,7 +68,8 @@ export default {
|
|
|
67
68
|
this.svg.then((el) => {
|
|
68
69
|
if (this._connected && el) {
|
|
69
70
|
applyAnimation(el);
|
|
70
|
-
|
|
71
|
+
registerObserver(
|
|
72
|
+
this,
|
|
71
73
|
observeIntersection(el, (records, observer) => {
|
|
72
74
|
applyAnimation(el);
|
|
73
75
|
observer.disconnect();
|
package/src/js/core/switcher.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import Lazyload from '../mixin/lazyload';
|
|
2
|
-
import Swipe from '../mixin/swipe';
|
|
3
1
|
import Togglable from '../mixin/togglable';
|
|
2
|
+
import { keyMap } from '../util/keys';
|
|
3
|
+
import { generateId } from '../api/instance';
|
|
4
|
+
import { lazyload, swipe } from '../api/observables';
|
|
4
5
|
import {
|
|
5
6
|
$$,
|
|
6
7
|
attr,
|
|
@@ -20,12 +21,11 @@ import {
|
|
|
20
21
|
toNodes,
|
|
21
22
|
within,
|
|
22
23
|
} from 'uikit-util';
|
|
23
|
-
import { generateId, keyMap } from '../mixin/utils';
|
|
24
24
|
|
|
25
25
|
const selDisabled = '.uk-disabled *, .uk-disabled, [disabled]';
|
|
26
26
|
|
|
27
27
|
export default {
|
|
28
|
-
mixins: [
|
|
28
|
+
mixins: [Togglable],
|
|
29
29
|
|
|
30
30
|
args: 'connect',
|
|
31
31
|
|
|
@@ -35,6 +35,7 @@ export default {
|
|
|
35
35
|
itemNav: String,
|
|
36
36
|
active: Number,
|
|
37
37
|
followFocus: Boolean,
|
|
38
|
+
swiping: Boolean,
|
|
38
39
|
},
|
|
39
40
|
|
|
40
41
|
data: {
|
|
@@ -46,6 +47,7 @@ export default {
|
|
|
46
47
|
attrItem: 'uk-switcher-item',
|
|
47
48
|
selVertical: '.uk-nav',
|
|
48
49
|
followFocus: false,
|
|
50
|
+
swiping: true,
|
|
49
51
|
},
|
|
50
52
|
|
|
51
53
|
computed: {
|
|
@@ -74,7 +76,6 @@ export default {
|
|
|
74
76
|
const index = this.index();
|
|
75
77
|
for (const el of this.connects) {
|
|
76
78
|
children(el).forEach((child, i) => toggleClass(child, this.cls, i === index));
|
|
77
|
-
this.lazyload(this.$el, children(el));
|
|
78
79
|
}
|
|
79
80
|
this.$emit();
|
|
80
81
|
},
|
|
@@ -101,16 +102,17 @@ export default {
|
|
|
101
102
|
this.toggles.some((toggle) => within(toggle, child))
|
|
102
103
|
);
|
|
103
104
|
},
|
|
104
|
-
|
|
105
|
-
swipeTarget() {
|
|
106
|
-
return this.connects;
|
|
107
|
-
},
|
|
108
105
|
},
|
|
109
106
|
|
|
110
107
|
connected() {
|
|
111
108
|
attr(this.$el, 'role', 'tablist');
|
|
112
109
|
},
|
|
113
110
|
|
|
111
|
+
observe: [
|
|
112
|
+
lazyload({ targets: ({ connectChildren }) => connectChildren }),
|
|
113
|
+
swipe({ target: ({ connects }) => connects, filter: ({ swiping }) => swiping }),
|
|
114
|
+
],
|
|
115
|
+
|
|
114
116
|
events: [
|
|
115
117
|
{
|
|
116
118
|
name: 'click keydown',
|
package/src/js/core/toggle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Lazyload from '../mixin/lazyload';
|
|
2
1
|
import Media from '../mixin/media';
|
|
3
2
|
import Togglable from '../mixin/togglable';
|
|
3
|
+
import { lazyload } from '../api/observables';
|
|
4
4
|
import {
|
|
5
5
|
attr,
|
|
6
6
|
closest,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
const KEY_SPACE = 32;
|
|
24
24
|
|
|
25
25
|
export default {
|
|
26
|
-
mixins: [
|
|
26
|
+
mixins: [Media, Togglable],
|
|
27
27
|
|
|
28
28
|
args: 'target',
|
|
29
29
|
|
|
@@ -57,10 +57,10 @@ export default {
|
|
|
57
57
|
attr(this.$el, 'role', 'button');
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
this.lazyload(this.$el, () => this.target);
|
|
62
60
|
},
|
|
63
61
|
|
|
62
|
+
observe: lazyload({ target: ({ target }) => target }),
|
|
63
|
+
|
|
64
64
|
events: [
|
|
65
65
|
{
|
|
66
66
|
name: pointerDown,
|
package/src/js/core/video.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
hasAttr,
|
|
4
|
-
isInView,
|
|
5
|
-
isTag,
|
|
6
|
-
isVideo,
|
|
7
|
-
isVisible,
|
|
8
|
-
mute,
|
|
9
|
-
observeIntersection,
|
|
10
|
-
pause,
|
|
11
|
-
play,
|
|
12
|
-
} from 'uikit-util';
|
|
1
|
+
import { intersection } from '../api/observables';
|
|
2
|
+
import { css, hasAttr, isInView, isTag, isVideo, isVisible, mute, pause, play } from 'uikit-util';
|
|
13
3
|
|
|
14
4
|
export default {
|
|
15
5
|
args: 'autoplay',
|
|
@@ -38,10 +28,12 @@ export default {
|
|
|
38
28
|
if (this.automute) {
|
|
39
29
|
mute(this.$el);
|
|
40
30
|
}
|
|
41
|
-
|
|
42
|
-
this.registerObserver(observeIntersection(this.$el, () => this.$emit(), {}, false));
|
|
43
31
|
},
|
|
44
32
|
|
|
33
|
+
observe: intersection({
|
|
34
|
+
args: { intersecting: false },
|
|
35
|
+
}),
|
|
36
|
+
|
|
45
37
|
update: {
|
|
46
38
|
read({ visible }) {
|
|
47
39
|
if (!isVideo(this.$el)) {
|
package/src/js/mixin/modal.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
endsWith,
|
|
11
11
|
includes,
|
|
12
12
|
isFocusable,
|
|
13
|
+
isSameSiteAnchor,
|
|
13
14
|
last,
|
|
14
15
|
matches,
|
|
15
16
|
on,
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
toFloat,
|
|
23
24
|
within,
|
|
24
25
|
} from 'uikit-util';
|
|
25
|
-
import {
|
|
26
|
+
import { preventBackgroundScroll } from '../util/scroll';
|
|
26
27
|
|
|
27
28
|
const active = [];
|
|
28
29
|
|
package/src/js/mixin/parallax.js
CHANGED
package/src/js/mixin/slider.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import I18n from './i18n';
|
|
2
|
-
import Resize from './resize';
|
|
3
2
|
import SliderNav from './slider-nav';
|
|
4
3
|
import SliderDrag from './slider-drag';
|
|
5
4
|
import SliderAutoplay from './slider-autoplay';
|
|
5
|
+
import { resize } from '../api/observables';
|
|
6
6
|
import {
|
|
7
7
|
$,
|
|
8
8
|
children,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from 'uikit-util';
|
|
17
17
|
|
|
18
18
|
export default {
|
|
19
|
-
mixins: [SliderAutoplay, SliderDrag, SliderNav,
|
|
19
|
+
mixins: [SliderAutoplay, SliderDrag, SliderNav, I18n],
|
|
20
20
|
|
|
21
21
|
props: {
|
|
22
22
|
clsActivated: Boolean,
|
|
@@ -78,6 +78,8 @@ export default {
|
|
|
78
78
|
},
|
|
79
79
|
},
|
|
80
80
|
|
|
81
|
+
observe: resize(),
|
|
82
|
+
|
|
81
83
|
methods: {
|
|
82
84
|
show(index, force = false) {
|
|
83
85
|
if (this.dragging || !this.length) {
|
|
@@ -144,7 +146,11 @@ export default {
|
|
|
144
146
|
},
|
|
145
147
|
|
|
146
148
|
getIndex(index = this.index, prev = this.index) {
|
|
147
|
-
return clamp(
|
|
149
|
+
return clamp(
|
|
150
|
+
getIndex(index, this.slides, prev, this.finite),
|
|
151
|
+
0,
|
|
152
|
+
Math.max(0, this.maxIndex)
|
|
153
|
+
);
|
|
148
154
|
},
|
|
149
155
|
|
|
150
156
|
getValidIndex(index = this.index, prevIndex = this.prevIndex) {
|
package/src/js/util/filter.js
CHANGED
|
@@ -84,3 +84,16 @@ export function children(element, selector) {
|
|
|
84
84
|
export function index(element, ref) {
|
|
85
85
|
return ref ? toNodes(element).indexOf(toNode(ref)) : children(parent(element)).indexOf(element);
|
|
86
86
|
}
|
|
87
|
+
|
|
88
|
+
export function isSameSiteAnchor(el) {
|
|
89
|
+
el = toNode(el);
|
|
90
|
+
return el && ['origin', 'pathname', 'search'].every((part) => el[part] === location[part]);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function getTargetedElement(el) {
|
|
94
|
+
if (isSameSiteAnchor(el)) {
|
|
95
|
+
el = toNode(el);
|
|
96
|
+
const id = decodeURIComponent(el.hash).substring(1);
|
|
97
|
+
return document.getElementById(id) || document.getElementsByName(id)[0];
|
|
98
|
+
}
|
|
99
|
+
}
|
package/src/js/util/index.js
CHANGED
package/src/js/util/lang.js
CHANGED
|
@@ -10,15 +10,11 @@ export const hyphenate = memoize((str) => str.replace(hyphenateRe, '-$1').toLowe
|
|
|
10
10
|
|
|
11
11
|
const camelizeRe = /-(\w)/g;
|
|
12
12
|
|
|
13
|
-
export const camelize = memoize((str) =>
|
|
14
|
-
|
|
15
|
-
export const ucfirst = memoize((str) =>
|
|
16
|
-
str.length ? toUpper(null, str.charAt(0)) + str.slice(1) : ''
|
|
13
|
+
export const camelize = memoize((str) =>
|
|
14
|
+
(str.charAt(0).toLowerCase() + str.slice(1)).replace(camelizeRe, (_, c) => c.toUpperCase())
|
|
17
15
|
);
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
return c ? c.toUpperCase() : '';
|
|
21
|
-
}
|
|
17
|
+
export const ucfirst = memoize((str) => str.charAt(0).toUpperCase() + str.slice(1));
|
|
22
18
|
|
|
23
19
|
export function startsWith(str, search) {
|
|
24
20
|
return str?.startsWith?.(search);
|
|
@@ -180,6 +176,10 @@ export function uniqueBy(array, prop) {
|
|
|
180
176
|
return array.filter(({ [prop]: check }) => (seen.has(check) ? false : seen.add(check)));
|
|
181
177
|
}
|
|
182
178
|
|
|
179
|
+
export function pick(obj, props) {
|
|
180
|
+
return props.reduce((res, prop) => ({ ...res, [prop]: obj[prop] }), {});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
183
|
export function clamp(number, min = 0, max = 1) {
|
|
184
184
|
return Math.min(Math.max(toNumber(number) || 0, min), max);
|
|
185
185
|
}
|
package/src/js/util/observer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { on } from './event';
|
|
2
|
-
import { toNodes } from './lang';
|
|
2
|
+
import { noop, toNodes } from './lang';
|
|
3
3
|
import { inBrowser } from './env';
|
|
4
4
|
|
|
5
|
-
export function observeIntersection(targets, cb, options, intersecting = true) {
|
|
5
|
+
export function observeIntersection(targets, cb, options = {}, intersecting = true) {
|
|
6
6
|
const observer = new IntersectionObserver(
|
|
7
7
|
intersecting
|
|
8
8
|
? (entries, observer) => {
|
|
@@ -31,6 +31,8 @@ export function observeResize(targets, cb, options = { box: 'border-box' }) {
|
|
|
31
31
|
listeners.add(cb);
|
|
32
32
|
|
|
33
33
|
return {
|
|
34
|
+
observe: noop,
|
|
35
|
+
unobserve: noop,
|
|
34
36
|
disconnect() {
|
|
35
37
|
listeners.delete(cb);
|
|
36
38
|
},
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { width } from './dimensions';
|
|
2
|
+
import { on } from './event';
|
|
3
|
+
import { css } from './style';
|
|
4
|
+
import { scrollParents } from './viewport';
|
|
5
|
+
|
|
6
|
+
let prevented;
|
|
7
|
+
export function preventBackgroundScroll(el) {
|
|
8
|
+
// 'overscroll-behavior: contain' only works consistently if el overflows (Safari)
|
|
9
|
+
const off = on(
|
|
10
|
+
el,
|
|
11
|
+
'touchmove',
|
|
12
|
+
(e) => {
|
|
13
|
+
if (e.targetTouches.length !== 1) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let [{ scrollHeight, clientHeight }] = scrollParents(e.target);
|
|
18
|
+
|
|
19
|
+
if (clientHeight >= scrollHeight && e.cancelable) {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{ passive: false }
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (prevented) {
|
|
27
|
+
return off;
|
|
28
|
+
}
|
|
29
|
+
prevented = true;
|
|
30
|
+
|
|
31
|
+
const { scrollingElement } = document;
|
|
32
|
+
css(scrollingElement, {
|
|
33
|
+
overflowY: CSS.supports('overflow', 'clip') ? 'clip' : 'hidden',
|
|
34
|
+
touchAction: 'none',
|
|
35
|
+
paddingRight: width(window) - scrollingElement.clientWidth || '',
|
|
36
|
+
});
|
|
37
|
+
return () => {
|
|
38
|
+
prevented = false;
|
|
39
|
+
off();
|
|
40
|
+
css(scrollingElement, { overflowY: '', touchAction: '', paddingRight: '' });
|
|
41
|
+
};
|
|
42
|
+
}
|
package/src/js/util/viewport.js
CHANGED
|
@@ -143,12 +143,12 @@ export function overflowParents(element) {
|
|
|
143
143
|
export function offsetViewport(scrollElement) {
|
|
144
144
|
const window = toWindow(scrollElement);
|
|
145
145
|
const {
|
|
146
|
+
visualViewport,
|
|
146
147
|
document: { documentElement },
|
|
147
148
|
} = window;
|
|
148
149
|
let viewportElement =
|
|
149
150
|
scrollElement === scrollingElement(scrollElement) ? window : scrollElement;
|
|
150
151
|
|
|
151
|
-
const { visualViewport } = window;
|
|
152
152
|
if (isWindow(viewportElement) && visualViewport) {
|
|
153
153
|
let { height, width, scale, pageTop: top, pageLeft: left } = visualViewport;
|
|
154
154
|
height = Math.round(height * scale);
|