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