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