uikit 3.11.1 → 3.11.2-dev.03e47c2ff
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 +59 -17
- 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 +127 -201
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +127 -201
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +129 -207
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +129 -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 -362
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +343 -350
- 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 -350
- 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 -621
- 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 +5430 -6690
- 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 +8143 -9784
- 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 +21 -46
- 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 +126 -108
- 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 +107 -93
- 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 +29 -36
- package/src/js/core/icon.js +47 -52
- package/src/js/core/img.js +156 -138
- 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 +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 +194 -123
- 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 +175 -121
- 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 +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 +78 -49
- package/src/js/util/dom.js +39 -66
- package/src/js/util/env.js +7 -12
- package/src/js/util/event.js +60 -59
- package/src/js/util/fastdom.js +3 -8
- 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 +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 +81 -66
- 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/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/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/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 -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 +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 +86 -98
- package/tests/sticky.html +56 -24
- 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/src/js/core/scrollspy.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
$$,
|
|
3
|
+
css,
|
|
4
|
+
filter,
|
|
5
|
+
data as getData,
|
|
6
|
+
isInView,
|
|
7
|
+
once,
|
|
8
|
+
removeClass,
|
|
9
|
+
removeClasses,
|
|
10
|
+
toggleClass,
|
|
11
|
+
trigger,
|
|
12
|
+
} from 'uikit-util';
|
|
2
13
|
|
|
3
14
|
const stateKey = '_ukScrollspy';
|
|
4
15
|
export default {
|
|
5
|
-
|
|
6
16
|
args: 'cls',
|
|
7
17
|
|
|
8
18
|
props: {
|
|
@@ -12,7 +22,7 @@ export default {
|
|
|
12
22
|
offsetTop: Number,
|
|
13
23
|
offsetLeft: Number,
|
|
14
24
|
repeat: Boolean,
|
|
15
|
-
delay: Number
|
|
25
|
+
delay: Number,
|
|
16
26
|
},
|
|
17
27
|
|
|
18
28
|
data: () => ({
|
|
@@ -23,14 +33,12 @@ export default {
|
|
|
23
33
|
offsetLeft: 0,
|
|
24
34
|
repeat: false,
|
|
25
35
|
delay: 0,
|
|
26
|
-
inViewClass: 'uk-scrollspy-inview'
|
|
36
|
+
inViewClass: 'uk-scrollspy-inview',
|
|
27
37
|
}),
|
|
28
38
|
|
|
29
39
|
computed: {
|
|
30
|
-
|
|
31
40
|
elements: {
|
|
32
|
-
|
|
33
|
-
get({target}, $el) {
|
|
41
|
+
get({ target }, $el) {
|
|
34
42
|
return target ? $$(target, $el) : [$el];
|
|
35
43
|
},
|
|
36
44
|
|
|
@@ -40,25 +48,20 @@ export default {
|
|
|
40
48
|
}
|
|
41
49
|
},
|
|
42
50
|
|
|
43
|
-
immediate: true
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
51
|
+
immediate: true,
|
|
52
|
+
},
|
|
47
53
|
},
|
|
48
54
|
|
|
49
55
|
disconnected() {
|
|
50
|
-
this.elements
|
|
56
|
+
for (const el of this.elements) {
|
|
51
57
|
removeClass(el, this.inViewClass, el[stateKey] ? el[stateKey].cls : '');
|
|
52
58
|
delete el[stateKey];
|
|
53
|
-
}
|
|
59
|
+
}
|
|
54
60
|
},
|
|
55
61
|
|
|
56
62
|
update: [
|
|
57
|
-
|
|
58
63
|
{
|
|
59
|
-
|
|
60
64
|
read(data) {
|
|
61
|
-
|
|
62
65
|
// Let child components be applied at least once first
|
|
63
66
|
if (!data.update) {
|
|
64
67
|
Promise.resolve().then(() => {
|
|
@@ -68,60 +71,43 @@ export default {
|
|
|
68
71
|
return false;
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
this.elements
|
|
72
|
-
|
|
74
|
+
for (const el of this.elements) {
|
|
73
75
|
if (!el[stateKey]) {
|
|
74
|
-
el[stateKey] = {cls: getData(el, 'uk-scrollspy-class') || this.cls};
|
|
76
|
+
el[stateKey] = { cls: getData(el, 'uk-scrollspy-class') || this.cls };
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
el[stateKey].show = isInView(el, this.offsetTop, this.offsetLeft);
|
|
78
|
-
|
|
79
|
-
});
|
|
80
|
-
|
|
80
|
+
}
|
|
81
81
|
},
|
|
82
82
|
|
|
83
83
|
write(data) {
|
|
84
|
-
|
|
85
|
-
this.elements.forEach(el => {
|
|
86
|
-
|
|
84
|
+
for (const el of this.elements) {
|
|
87
85
|
const state = el[stateKey];
|
|
88
86
|
|
|
89
87
|
if (state.show && !state.inview && !state.queued) {
|
|
90
|
-
|
|
91
88
|
state.queued = true;
|
|
92
89
|
|
|
93
|
-
data.promise = (data.promise || Promise.resolve())
|
|
94
|
-
new Promise(resolve =>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}, 300);
|
|
103
|
-
});
|
|
104
|
-
|
|
90
|
+
data.promise = (data.promise || Promise.resolve())
|
|
91
|
+
.then(() => new Promise((resolve) => setTimeout(resolve, this.delay)))
|
|
92
|
+
.then(() => {
|
|
93
|
+
this.toggle(el, true);
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
state.queued = false;
|
|
96
|
+
this.$emit();
|
|
97
|
+
}, 300);
|
|
98
|
+
});
|
|
105
99
|
} else if (!state.show && state.inview && !state.queued && this.repeat) {
|
|
106
|
-
|
|
107
100
|
this.toggle(el, false);
|
|
108
|
-
|
|
109
101
|
}
|
|
110
|
-
|
|
111
|
-
});
|
|
112
|
-
|
|
102
|
+
}
|
|
113
103
|
},
|
|
114
104
|
|
|
115
|
-
events: ['scroll', 'resize']
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
105
|
+
events: ['scroll', 'resize'],
|
|
106
|
+
},
|
|
119
107
|
],
|
|
120
108
|
|
|
121
109
|
methods: {
|
|
122
|
-
|
|
123
110
|
toggle(el, inview) {
|
|
124
|
-
|
|
125
111
|
const state = el[stateKey];
|
|
126
112
|
|
|
127
113
|
state.off && state.off();
|
|
@@ -142,9 +128,6 @@ export default {
|
|
|
142
128
|
state.inview = inview;
|
|
143
129
|
|
|
144
130
|
this.$update(el);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
131
|
+
},
|
|
132
|
+
},
|
|
149
133
|
};
|
|
150
|
-
|
package/src/js/core/sticky.js
CHANGED
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
import Class from '../mixin/class';
|
|
2
2
|
import Media from '../mixin/media';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
$,
|
|
5
|
+
addClass,
|
|
6
|
+
after,
|
|
7
|
+
Animation,
|
|
8
|
+
clamp,
|
|
9
|
+
css,
|
|
10
|
+
dimensions,
|
|
11
|
+
fastdom,
|
|
12
|
+
height as getHeight,
|
|
13
|
+
offset as getOffset,
|
|
14
|
+
getScrollingElement,
|
|
15
|
+
hasClass,
|
|
16
|
+
isNumeric,
|
|
17
|
+
isString,
|
|
18
|
+
isVisible,
|
|
19
|
+
noop,
|
|
20
|
+
offsetPosition,
|
|
21
|
+
parent,
|
|
22
|
+
query,
|
|
23
|
+
remove,
|
|
24
|
+
removeClass,
|
|
25
|
+
replaceClass,
|
|
26
|
+
scrollTop,
|
|
27
|
+
toFloat,
|
|
28
|
+
toggleClass,
|
|
29
|
+
toPx,
|
|
30
|
+
trigger,
|
|
31
|
+
within,
|
|
32
|
+
} from 'uikit-util';
|
|
4
33
|
|
|
5
34
|
export default {
|
|
6
|
-
|
|
7
35
|
mixins: [Class, Media],
|
|
8
36
|
|
|
9
37
|
props: {
|
|
38
|
+
position: String,
|
|
10
39
|
top: null,
|
|
11
40
|
bottom: Boolean,
|
|
12
41
|
offset: String,
|
|
@@ -18,10 +47,11 @@ export default {
|
|
|
18
47
|
selTarget: String,
|
|
19
48
|
widthElement: Boolean,
|
|
20
49
|
showOnUp: Boolean,
|
|
21
|
-
targetOffset: Number
|
|
50
|
+
targetOffset: Number,
|
|
22
51
|
},
|
|
23
52
|
|
|
24
53
|
data: {
|
|
54
|
+
position: 'top',
|
|
25
55
|
top: 0,
|
|
26
56
|
bottom: false,
|
|
27
57
|
offset: 0,
|
|
@@ -33,25 +63,19 @@ export default {
|
|
|
33
63
|
selTarget: '',
|
|
34
64
|
widthElement: false,
|
|
35
65
|
showOnUp: false,
|
|
36
|
-
targetOffset: false
|
|
66
|
+
targetOffset: false,
|
|
37
67
|
},
|
|
38
68
|
|
|
39
69
|
computed: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return toPx(offset);
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
selTarget({selTarget}, $el) {
|
|
46
|
-
return selTarget && $(selTarget, $el) || $el;
|
|
70
|
+
selTarget({ selTarget }, $el) {
|
|
71
|
+
return (selTarget && $(selTarget, $el)) || $el;
|
|
47
72
|
},
|
|
48
73
|
|
|
49
|
-
widthElement({widthElement}, $el) {
|
|
74
|
+
widthElement({ widthElement }, $el) {
|
|
50
75
|
return query(widthElement, $el) || this.placeholder;
|
|
51
76
|
},
|
|
52
77
|
|
|
53
78
|
isActive: {
|
|
54
|
-
|
|
55
79
|
get() {
|
|
56
80
|
return hasClass(this.selTarget, this.clsActive);
|
|
57
81
|
},
|
|
@@ -64,20 +88,19 @@ export default {
|
|
|
64
88
|
replaceClass(this.selTarget, this.clsActive, this.clsInactive);
|
|
65
89
|
trigger(this.$el, 'inactive');
|
|
66
90
|
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
91
|
+
},
|
|
92
|
+
},
|
|
71
93
|
},
|
|
72
94
|
|
|
73
95
|
connected() {
|
|
74
|
-
this.placeholder =
|
|
96
|
+
this.placeholder =
|
|
97
|
+
$('+ .uk-sticky-placeholder', this.$el) ||
|
|
98
|
+
$('<div class="uk-sticky-placeholder"></div>');
|
|
75
99
|
this.isFixed = false;
|
|
76
100
|
this.isActive = false;
|
|
77
101
|
},
|
|
78
102
|
|
|
79
103
|
disconnected() {
|
|
80
|
-
|
|
81
104
|
if (this.isFixed) {
|
|
82
105
|
this.hide();
|
|
83
106
|
removeClass(this.selTarget, this.clsInactive);
|
|
@@ -89,9 +112,7 @@ export default {
|
|
|
89
112
|
},
|
|
90
113
|
|
|
91
114
|
events: [
|
|
92
|
-
|
|
93
115
|
{
|
|
94
|
-
|
|
95
116
|
name: 'load hashchange popstate',
|
|
96
117
|
|
|
97
118
|
el() {
|
|
@@ -99,8 +120,7 @@ export default {
|
|
|
99
120
|
},
|
|
100
121
|
|
|
101
122
|
handler() {
|
|
102
|
-
|
|
103
|
-
if (!(this.targetOffset !== false && location.hash && window.pageYOffset > 0)) {
|
|
123
|
+
if (!(this.targetOffset !== false && location.hash && scrollTop(window) > 0)) {
|
|
104
124
|
return;
|
|
105
125
|
}
|
|
106
126
|
|
|
@@ -108,72 +128,99 @@ export default {
|
|
|
108
128
|
|
|
109
129
|
if (target) {
|
|
110
130
|
fastdom.read(() => {
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
const elTop = offset(this.$el).top;
|
|
131
|
+
const { top } = getOffset(target);
|
|
132
|
+
const elTop = getOffset(this.$el).top;
|
|
114
133
|
const elHeight = this.$el.offsetHeight;
|
|
115
134
|
|
|
116
|
-
if (
|
|
117
|
-
|
|
135
|
+
if (
|
|
136
|
+
this.isFixed &&
|
|
137
|
+
elTop + elHeight >= top &&
|
|
138
|
+
elTop <= top + target.offsetHeight
|
|
139
|
+
) {
|
|
140
|
+
scrollTop(
|
|
141
|
+
window,
|
|
142
|
+
top -
|
|
143
|
+
elHeight -
|
|
144
|
+
(isNumeric(this.targetOffset) ? this.targetOffset : 0) -
|
|
145
|
+
this._data.offset
|
|
146
|
+
);
|
|
118
147
|
}
|
|
119
|
-
|
|
120
148
|
});
|
|
121
149
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
150
|
+
},
|
|
151
|
+
},
|
|
127
152
|
],
|
|
128
153
|
|
|
129
154
|
update: [
|
|
130
|
-
|
|
131
155
|
{
|
|
132
|
-
|
|
133
|
-
read({height}, types) {
|
|
134
|
-
|
|
156
|
+
read({ height, margin }, types) {
|
|
135
157
|
this.inactive = !this.matchMedia || !isVisible(this.$el);
|
|
136
158
|
|
|
137
159
|
if (this.inactive) {
|
|
138
160
|
return false;
|
|
139
161
|
}
|
|
140
162
|
|
|
141
|
-
|
|
163
|
+
const hide = this.isActive && types.has('resize');
|
|
164
|
+
if (hide) {
|
|
165
|
+
css(this.selTarget, 'transition', '0s');
|
|
142
166
|
this.hide();
|
|
143
|
-
height = this.$el.offsetHeight;
|
|
144
|
-
this.show();
|
|
145
167
|
}
|
|
146
168
|
|
|
147
|
-
|
|
169
|
+
if (!this.isActive) {
|
|
170
|
+
height = getOffset(this.$el).height;
|
|
171
|
+
margin = css(this.$el, 'margin');
|
|
172
|
+
}
|
|
148
173
|
|
|
149
|
-
if (
|
|
150
|
-
this.
|
|
151
|
-
|
|
174
|
+
if (hide) {
|
|
175
|
+
this.show();
|
|
176
|
+
fastdom.write(() => css(this.selTarget, 'transition', ''));
|
|
152
177
|
}
|
|
153
178
|
|
|
154
179
|
const referenceElement = this.isFixed ? this.placeholder : this.$el;
|
|
155
|
-
this.topOffset = offset(referenceElement).top;
|
|
156
|
-
this.bottomOffset = this.topOffset + height;
|
|
157
|
-
this.offsetParentTop = offset(referenceElement.offsetParent).top;
|
|
158
180
|
|
|
159
|
-
|
|
181
|
+
let position = this.position;
|
|
160
182
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
183
|
+
if (position === 'auto') {
|
|
184
|
+
position = height > getHeight(window) ? 'bottom' : 'top';
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
let offset = this.offset;
|
|
188
|
+
if (position === 'bottom') {
|
|
189
|
+
offset += '+100vh-100%';
|
|
190
|
+
}
|
|
191
|
+
offset = toPx(offset, 'height', referenceElement);
|
|
192
|
+
|
|
193
|
+
const overflow = Math.max(0, height + offset - getHeight(window));
|
|
194
|
+
const topOffset = getOffset(referenceElement).top;
|
|
195
|
+
const offsetParentTop = getOffset(referenceElement.offsetParent).top;
|
|
196
|
+
|
|
197
|
+
const top = parseProp(this.top, this.$el, topOffset);
|
|
198
|
+
const bottom = parseProp(this.bottom, this.$el, topOffset + height, true);
|
|
199
|
+
|
|
200
|
+
const start = Math.max(top, topOffset) - offset;
|
|
201
|
+
const end = bottom
|
|
202
|
+
? bottom - getOffset(this.$el).height + overflow - offset
|
|
203
|
+
: getScrollingElement(this.$el).scrollHeight - getHeight(window);
|
|
164
204
|
|
|
165
205
|
return {
|
|
206
|
+
start,
|
|
207
|
+
end,
|
|
208
|
+
offset,
|
|
209
|
+
overflow,
|
|
210
|
+
topOffset,
|
|
211
|
+
offsetParentTop,
|
|
166
212
|
height,
|
|
167
|
-
|
|
168
|
-
|
|
213
|
+
margin,
|
|
214
|
+
width: dimensions(isVisible(this.widthElement) ? this.widthElement : this.$el)
|
|
215
|
+
.width,
|
|
216
|
+
top: offsetPosition(referenceElement)[0],
|
|
169
217
|
};
|
|
170
218
|
},
|
|
171
219
|
|
|
172
|
-
write({height,
|
|
220
|
+
write({ height, margin }) {
|
|
221
|
+
const { placeholder } = this;
|
|
173
222
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
css(placeholder, assign({height}, margins));
|
|
223
|
+
css(placeholder, { height, margin });
|
|
177
224
|
|
|
178
225
|
if (!within(placeholder, document)) {
|
|
179
226
|
after(this.$el, placeholder);
|
|
@@ -181,55 +228,82 @@ export default {
|
|
|
181
228
|
}
|
|
182
229
|
|
|
183
230
|
this.isActive = !!this.isActive; // force self-assign
|
|
184
|
-
|
|
185
231
|
},
|
|
186
232
|
|
|
187
|
-
events: ['resize']
|
|
188
|
-
|
|
233
|
+
events: ['resize'],
|
|
189
234
|
},
|
|
190
235
|
|
|
191
236
|
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
237
|
+
read({
|
|
238
|
+
scroll: prevScroll = 0,
|
|
239
|
+
dir: prevDir = 'down',
|
|
240
|
+
overflow,
|
|
241
|
+
overflowScroll = 0,
|
|
242
|
+
start,
|
|
243
|
+
end,
|
|
244
|
+
}) {
|
|
245
|
+
const scroll = scrollTop(window);
|
|
246
|
+
const dir = prevScroll <= scroll ? 'down' : 'up';
|
|
196
247
|
|
|
197
248
|
return {
|
|
198
|
-
dir
|
|
199
|
-
|
|
249
|
+
dir,
|
|
250
|
+
prevDir,
|
|
251
|
+
scroll,
|
|
252
|
+
prevScroll,
|
|
253
|
+
overflowScroll: clamp(
|
|
254
|
+
overflowScroll + clamp(scroll, start, end) - clamp(prevScroll, start, end),
|
|
255
|
+
0,
|
|
256
|
+
overflow
|
|
257
|
+
),
|
|
200
258
|
};
|
|
201
259
|
},
|
|
202
260
|
|
|
203
261
|
write(data, types) {
|
|
204
|
-
|
|
205
|
-
const now = Date.now();
|
|
206
262
|
const isScrollUpdate = types.has('scroll');
|
|
207
|
-
const {
|
|
208
|
-
|
|
209
|
-
|
|
263
|
+
const {
|
|
264
|
+
initTimestamp = 0,
|
|
265
|
+
dir,
|
|
266
|
+
prevDir,
|
|
267
|
+
scroll,
|
|
268
|
+
prevScroll = 0,
|
|
269
|
+
top,
|
|
270
|
+
start,
|
|
271
|
+
topOffset,
|
|
272
|
+
height,
|
|
273
|
+
} = data;
|
|
210
274
|
|
|
211
|
-
if (
|
|
275
|
+
if (
|
|
276
|
+
scroll < 0 ||
|
|
277
|
+
(scroll === prevScroll && isScrollUpdate) ||
|
|
278
|
+
(this.showOnUp && !isScrollUpdate && !this.isFixed)
|
|
279
|
+
) {
|
|
212
280
|
return;
|
|
213
281
|
}
|
|
214
282
|
|
|
215
|
-
|
|
283
|
+
const now = Date.now();
|
|
284
|
+
if (now - initTimestamp > 300 || dir !== prevDir) {
|
|
216
285
|
data.initScroll = scroll;
|
|
217
286
|
data.initTimestamp = now;
|
|
218
287
|
}
|
|
219
288
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
289
|
+
if (
|
|
290
|
+
this.showOnUp &&
|
|
291
|
+
!this.isFixed &&
|
|
292
|
+
Math.abs(data.initScroll - scroll) <= 30 &&
|
|
293
|
+
Math.abs(prevScroll - scroll) <= 10
|
|
294
|
+
) {
|
|
223
295
|
return;
|
|
224
296
|
}
|
|
225
297
|
|
|
226
|
-
if (
|
|
227
|
-
|
|
228
|
-
|
|
298
|
+
if (
|
|
299
|
+
this.inactive ||
|
|
300
|
+
scroll < start ||
|
|
301
|
+
(this.showOnUp &&
|
|
302
|
+
(scroll <= start ||
|
|
303
|
+
(dir === 'down' && isScrollUpdate) ||
|
|
304
|
+
(dir === 'up' && !this.isFixed && scroll <= topOffset + height)))
|
|
229
305
|
) {
|
|
230
|
-
|
|
231
306
|
if (!this.isFixed) {
|
|
232
|
-
|
|
233
307
|
if (Animation.inProgress(this.$el) && top > scroll) {
|
|
234
308
|
Animation.cancel(this.$el);
|
|
235
309
|
this.hide();
|
|
@@ -240,96 +314,93 @@ export default {
|
|
|
240
314
|
|
|
241
315
|
this.isFixed = false;
|
|
242
316
|
|
|
243
|
-
if (this.animation && scroll >
|
|
317
|
+
if (this.animation && scroll > topOffset) {
|
|
244
318
|
Animation.cancel(this.$el);
|
|
245
319
|
Animation.out(this.$el, this.animation).then(() => this.hide(), noop);
|
|
246
320
|
} else {
|
|
247
321
|
this.hide();
|
|
248
322
|
}
|
|
249
|
-
|
|
250
323
|
} else if (this.isFixed) {
|
|
251
|
-
|
|
252
324
|
this.update();
|
|
253
|
-
|
|
254
|
-
} else if (this.animation) {
|
|
255
|
-
|
|
325
|
+
} else if (this.animation && scroll > topOffset) {
|
|
256
326
|
Animation.cancel(this.$el);
|
|
257
327
|
this.show();
|
|
258
328
|
Animation.in(this.$el, this.animation).catch(noop);
|
|
259
|
-
|
|
260
329
|
} else {
|
|
261
330
|
this.show();
|
|
262
331
|
}
|
|
263
|
-
|
|
264
332
|
},
|
|
265
333
|
|
|
266
|
-
events: ['resize', 'scroll']
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
334
|
+
events: ['resize', 'scroll'],
|
|
335
|
+
},
|
|
270
336
|
],
|
|
271
337
|
|
|
272
338
|
methods: {
|
|
273
|
-
|
|
274
339
|
show() {
|
|
275
|
-
|
|
276
340
|
this.isFixed = true;
|
|
277
341
|
this.update();
|
|
278
342
|
this.placeholder.hidden = false;
|
|
279
|
-
|
|
280
343
|
},
|
|
281
344
|
|
|
282
345
|
hide() {
|
|
283
|
-
|
|
284
346
|
this.isActive = false;
|
|
285
347
|
removeClass(this.$el, this.clsFixed, this.clsBelow);
|
|
286
|
-
css(this.$el, {position: '', top: '', width: ''});
|
|
348
|
+
css(this.$el, { position: '', top: '', width: '' });
|
|
287
349
|
this.placeholder.hidden = true;
|
|
288
|
-
|
|
289
350
|
},
|
|
290
351
|
|
|
291
352
|
update() {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
353
|
+
let {
|
|
354
|
+
width,
|
|
355
|
+
scroll = 0,
|
|
356
|
+
overflow,
|
|
357
|
+
overflowScroll = 0,
|
|
358
|
+
start,
|
|
359
|
+
end,
|
|
360
|
+
offset,
|
|
361
|
+
topOffset,
|
|
362
|
+
height,
|
|
363
|
+
offsetParentTop,
|
|
364
|
+
} = this._data;
|
|
365
|
+
const active = start !== 0 || scroll > start;
|
|
295
366
|
let position = 'fixed';
|
|
296
367
|
|
|
297
|
-
if (
|
|
298
|
-
|
|
368
|
+
if (scroll > end) {
|
|
369
|
+
offset += end - offsetParentTop;
|
|
299
370
|
position = 'absolute';
|
|
300
371
|
}
|
|
301
372
|
|
|
373
|
+
if (overflow) {
|
|
374
|
+
offset -= overflowScroll;
|
|
375
|
+
}
|
|
376
|
+
|
|
302
377
|
css(this.$el, {
|
|
303
378
|
position,
|
|
304
|
-
top: `${
|
|
305
|
-
width
|
|
379
|
+
top: `${offset}px`,
|
|
380
|
+
width,
|
|
306
381
|
});
|
|
307
382
|
|
|
308
383
|
this.isActive = active;
|
|
309
|
-
toggleClass(this.$el, this.clsBelow,
|
|
384
|
+
toggleClass(this.$el, this.clsBelow, scroll > topOffset + height);
|
|
310
385
|
addClass(this.$el, this.clsFixed);
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
386
|
+
},
|
|
387
|
+
},
|
|
316
388
|
};
|
|
317
389
|
|
|
318
|
-
function parseProp(
|
|
319
|
-
|
|
320
|
-
const value = $props[prop];
|
|
321
|
-
|
|
390
|
+
function parseProp(value, el, propOffset, padding) {
|
|
322
391
|
if (!value) {
|
|
323
|
-
return;
|
|
392
|
+
return 0;
|
|
324
393
|
}
|
|
325
394
|
|
|
326
395
|
if (isString(value) && value.match(/^-?\d/)) {
|
|
327
|
-
|
|
328
396
|
return propOffset + toPx(value);
|
|
329
|
-
|
|
330
397
|
} else {
|
|
331
|
-
|
|
332
|
-
return
|
|
333
|
-
|
|
398
|
+
const refElement = value === true ? parent(el) : query(value, el);
|
|
399
|
+
return (
|
|
400
|
+
getOffset(refElement).bottom -
|
|
401
|
+
(padding && refElement && within(el, refElement)
|
|
402
|
+
? toFloat(css(refElement, 'paddingBottom'))
|
|
403
|
+
: 0)
|
|
404
|
+
);
|
|
334
405
|
}
|
|
335
406
|
}
|