uikit 3.11.2-dev.57792c7e7 → 3.11.2-dev.72dbb9a19
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 +21 -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 +42 -32
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +42 -32
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +42 -32
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +42 -32
- 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 +297 -352
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +295 -340
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +722 -852
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +295 -340
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +612 -802
- 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 +5370 -6659
- 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 +7904 -9673
- 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-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 +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 +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 +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 +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 +187 -116
- 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 +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 +80 -64
- 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 +20 -39
- 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 +76 -47
- 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 +3 -8
- package/src/js/util/filter.js +17 -34
- package/src/js/util/index.js +0 -1
- package/src/js/util/lang.js +81 -121
- package/src/js/util/mouse.js +19 -17
- package/src/js/util/options.js +35 -49
- package/src/js/util/player.js +40 -36
- package/src/js/util/position.js +54 -46
- package/src/js/util/selector.js +43 -58
- package/src/js/util/style.js +36 -46
- package/src/js/util/viewport.js +81 -66
- package/src/less/components/base.less +0 -5
- package/src/less/components/flex.less +0 -9
- package/src/less/components/leader.less +0 -1
- package/src/less/components/navbar.less +0 -7
- package/src/less/components/utility.less +22 -0
- package/src/scss/components/base.scss +0 -5
- package/src/scss/components/flex.scss +0 -9
- package/src/scss/components/form.scss +3 -3
- package/src/scss/components/icon.scss +2 -2
- package/src/scss/components/leader.scss +0 -1
- package/src/scss/components/navbar.scss +0 -7
- package/src/scss/components/search.scss +1 -1
- package/src/scss/components/utility.scss +22 -0
- package/src/scss/variables-theme.scss +6 -6
- package/src/scss/variables.scss +6 -6
- package/tests/js/index.js +114 -85
- package/tests/sticky-parallax.html +44 -41
- package/tests/sticky.html +56 -24
- package/src/js/mixin/flex-bug.js +0 -56
- package/src/js/util/promise.js +0 -191
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! UIkit 3.11.2-dev.
|
|
1
|
+
/*! UIkit 3.11.2-dev.72dbb9a19 | https://www.getuikit.com | (c) 2014 - 2022 YOOtheme | MIT License */
|
|
2
2
|
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('uikit-util')) :
|
|
@@ -7,498 +7,443 @@
|
|
|
7
7
|
})(this, (function (uikitUtil) { 'use strict';
|
|
8
8
|
|
|
9
9
|
var Media = {
|
|
10
|
+
props: {
|
|
11
|
+
media: Boolean },
|
|
10
12
|
|
|
11
|
-
props: {
|
|
12
|
-
media: Boolean
|
|
13
|
-
},
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
14
|
+
data: {
|
|
15
|
+
media: false },
|
|
18
16
|
|
|
19
|
-
computed: {
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
computed: {
|
|
19
|
+
matchMedia() {
|
|
20
|
+
const media = toMedia(this.media);
|
|
21
|
+
return !media || window.matchMedia(media).matches;
|
|
22
|
+
} } };
|
|
25
23
|
|
|
26
|
-
}
|
|
27
24
|
|
|
28
|
-
};
|
|
29
25
|
|
|
30
26
|
function toMedia(value) {
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
27
|
+
if (uikitUtil.isString(value)) {
|
|
28
|
+
if (value[0] === '@') {
|
|
29
|
+
const name = "breakpoint-" + value.substr(1);
|
|
30
|
+
value = uikitUtil.toFloat(uikitUtil.getCssVar(name));
|
|
31
|
+
} else if (isNaN(value)) {
|
|
32
|
+
return value;
|
|
39
33
|
}
|
|
34
|
+
}
|
|
40
35
|
|
|
41
|
-
|
|
36
|
+
return value && !isNaN(value) ? "(min-width: " + value + "px)" : false;
|
|
42
37
|
}
|
|
43
38
|
|
|
44
|
-
uikitUtil.memoize(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
uikitUtil.memoize(async (src) => {
|
|
40
|
+
if (src) {
|
|
41
|
+
if (uikitUtil.startsWith(src, 'data:')) {
|
|
42
|
+
return decodeURIComponent(src.split(',')[1]);
|
|
43
|
+
} else {
|
|
44
|
+
return (await fetch(src)).text();
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
return Promise.reject();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
function getMaxPathLength(el) {
|
|
52
|
+
return Math.ceil(
|
|
53
|
+
Math.max(
|
|
54
|
+
0,
|
|
55
|
+
...uikitUtil.$$('[stroke]', el).map((stroke) => {
|
|
56
|
+
try {
|
|
57
|
+
return stroke.getTotalLength();
|
|
58
|
+
} catch (e) {
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
})));
|
|
59
62
|
|
|
60
|
-
}
|
|
61
|
-
}); }
|
|
62
|
-
);
|
|
63
63
|
|
|
64
|
-
function getMaxPathLength(el) {
|
|
65
|
-
return Math.ceil(Math.max.apply(Math, [ 0 ].concat( uikitUtil.$$('[stroke]', el).map(function (stroke) {
|
|
66
|
-
try {
|
|
67
|
-
return stroke.getTotalLength();
|
|
68
|
-
} catch (e) {
|
|
69
|
-
return 0;
|
|
70
|
-
}
|
|
71
|
-
}) )));
|
|
72
64
|
}
|
|
73
65
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
66
|
+
const props = {
|
|
67
|
+
x: transformFn,
|
|
68
|
+
y: transformFn,
|
|
69
|
+
rotate: transformFn,
|
|
70
|
+
scale: transformFn,
|
|
71
|
+
color: colorFn,
|
|
72
|
+
backgroundColor: colorFn,
|
|
73
|
+
borderColor: colorFn,
|
|
74
|
+
blur: filterFn,
|
|
75
|
+
hue: filterFn,
|
|
76
|
+
fopacity: filterFn,
|
|
77
|
+
grayscale: filterFn,
|
|
78
|
+
invert: filterFn,
|
|
79
|
+
saturate: filterFn,
|
|
80
|
+
sepia: filterFn,
|
|
81
|
+
opacity: cssPropFn,
|
|
82
|
+
stroke: strokeFn,
|
|
83
|
+
bgx: backgroundFn,
|
|
84
|
+
bgy: backgroundFn };
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const { keys } = Object;
|
|
96
88
|
|
|
97
89
|
var Parallax = {
|
|
90
|
+
mixins: [Media],
|
|
98
91
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
props: fillObject(keys(props), 'list'),
|
|
102
|
-
|
|
103
|
-
data: fillObject(keys(props), undefined),
|
|
104
|
-
|
|
105
|
-
computed: {
|
|
92
|
+
props: fillObject(keys(props), 'list'),
|
|
106
93
|
|
|
107
|
-
|
|
108
|
-
var this$1$1 = this;
|
|
94
|
+
data: fillObject(keys(props), undefined),
|
|
109
95
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}, {});
|
|
96
|
+
computed: {
|
|
97
|
+
props(properties, $el) {
|
|
98
|
+
return keys(props).reduce((result, prop) => {
|
|
99
|
+
if (!uikitUtil.isUndefined(properties[prop])) {
|
|
100
|
+
result[prop] = props[prop](prop, $el, properties[prop].slice());
|
|
116
101
|
}
|
|
102
|
+
return result;
|
|
103
|
+
}, {});
|
|
104
|
+
} },
|
|
117
105
|
|
|
118
|
-
},
|
|
119
106
|
|
|
120
|
-
|
|
107
|
+
events: {
|
|
108
|
+
bgimageload() {
|
|
109
|
+
this.$emit();
|
|
110
|
+
} },
|
|
121
111
|
|
|
122
|
-
reset: function() {
|
|
123
|
-
var this$1$1 = this;
|
|
124
112
|
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
methods: {
|
|
114
|
+
reset() {
|
|
115
|
+
uikitUtil.each(this.getCss(0), (_, prop) => uikitUtil.css(this.$el, prop, ''));
|
|
116
|
+
},
|
|
127
117
|
|
|
128
|
-
|
|
129
|
-
|
|
118
|
+
getCss(percent) {
|
|
119
|
+
return keys(this.props).reduce(
|
|
120
|
+
(css, prop) => {
|
|
121
|
+
this.props[prop](css, percent);
|
|
122
|
+
return css;
|
|
123
|
+
},
|
|
124
|
+
{ transform: '', filter: '' });
|
|
130
125
|
|
|
131
|
-
|
|
132
|
-
this$1$1.props[prop](css, percent);
|
|
133
|
-
return css;
|
|
134
|
-
}, {transform: '', filter: ''});
|
|
135
|
-
}
|
|
126
|
+
} } };
|
|
136
127
|
|
|
137
|
-
}
|
|
138
128
|
|
|
139
|
-
};
|
|
140
129
|
|
|
141
130
|
function transformFn(prop, el, steps) {
|
|
131
|
+
const unit = getUnit(steps) || { x: 'px', y: 'px', rotate: 'deg' }[prop] || '';
|
|
142
132
|
|
|
143
|
-
|
|
133
|
+
if (prop === 'x' || prop === 'y') {
|
|
134
|
+
prop = "translate" + uikitUtil.ucfirst(prop);
|
|
135
|
+
}
|
|
144
136
|
|
|
145
|
-
|
|
146
|
-
prop = "translate" + (uikitUtil.ucfirst(prop));
|
|
147
|
-
}
|
|
137
|
+
steps = steps.map(uikitUtil.toFloat);
|
|
148
138
|
|
|
149
|
-
|
|
139
|
+
if (steps.length === 1) {
|
|
140
|
+
steps.unshift(prop === 'scale' ? 1 : 0);
|
|
141
|
+
}
|
|
150
142
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return function (css, percent) {
|
|
156
|
-
var value = getValue(steps, percent);
|
|
143
|
+
return (css, percent) => {
|
|
144
|
+
let value = getValue(steps, percent);
|
|
157
145
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
146
|
+
if (uikitUtil.startsWith(prop, 'translate')) {
|
|
147
|
+
value = uikitUtil.toFloat(value).toFixed(unit === 'px' ? 0 : 6);
|
|
148
|
+
}
|
|
161
149
|
|
|
162
|
-
|
|
163
|
-
|
|
150
|
+
css.transform += " " + prop + "(" + value + unit + ")";
|
|
151
|
+
};
|
|
164
152
|
}
|
|
165
153
|
|
|
166
154
|
function colorFn(prop, el, steps) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}).join(',');
|
|
184
|
-
css[prop] = "rgba(" + value + ")";
|
|
185
|
-
};
|
|
155
|
+
if (steps.length === 1) {
|
|
156
|
+
steps.unshift(getCssValue(el, prop, ''));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
steps = steps.map((step) => parseColor(el, step));
|
|
160
|
+
|
|
161
|
+
return (css, percent) => {
|
|
162
|
+
const [start, end, p] = getStep(steps, percent);
|
|
163
|
+
const value = start.
|
|
164
|
+
map((value, i) => {
|
|
165
|
+
value += p * (end[i] - value);
|
|
166
|
+
return i === 3 ? uikitUtil.toFloat(value) : parseInt(value, 10);
|
|
167
|
+
}).
|
|
168
|
+
join(',');
|
|
169
|
+
css[prop] = "rgba(" + value + ")";
|
|
170
|
+
};
|
|
186
171
|
}
|
|
187
172
|
|
|
188
173
|
function parseColor(el, color) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
174
|
+
return getCssValue(el, 'color', color).
|
|
175
|
+
split(/[(),]/g).
|
|
176
|
+
slice(1, -1).
|
|
177
|
+
concat(1).
|
|
178
|
+
slice(0, 4).
|
|
179
|
+
map(uikitUtil.toFloat);
|
|
195
180
|
}
|
|
196
181
|
|
|
197
182
|
function filterFn(prop, el, steps) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
};
|
|
183
|
+
if (steps.length === 1) {
|
|
184
|
+
steps.unshift(0);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const unit = getUnit(steps) || { blur: 'px', hue: 'deg' }[prop] || '%';
|
|
188
|
+
prop = { fopacity: 'opacity', hue: 'hue-rotate' }[prop] || prop;
|
|
189
|
+
steps = steps.map(uikitUtil.toFloat);
|
|
190
|
+
|
|
191
|
+
return (css, percent) => {
|
|
192
|
+
const value = getValue(steps, percent);
|
|
193
|
+
css.filter += " " + prop + "(" + (value + unit) + ")";
|
|
194
|
+
};
|
|
211
195
|
}
|
|
212
196
|
|
|
213
197
|
function cssPropFn(prop, el, steps) {
|
|
198
|
+
if (steps.length === 1) {
|
|
199
|
+
steps.unshift(getCssValue(el, prop, ''));
|
|
200
|
+
}
|
|
214
201
|
|
|
215
|
-
|
|
216
|
-
steps.unshift(getCssValue(el, prop, ''));
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
steps = steps.map(uikitUtil.toFloat);
|
|
202
|
+
steps = steps.map(uikitUtil.toFloat);
|
|
220
203
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
204
|
+
return (css, percent) => {
|
|
205
|
+
css[prop] = getValue(steps, percent);
|
|
206
|
+
};
|
|
224
207
|
}
|
|
225
208
|
|
|
226
209
|
function strokeFn(prop, el, steps) {
|
|
210
|
+
if (steps.length === 1) {
|
|
211
|
+
steps.unshift(0);
|
|
212
|
+
}
|
|
227
213
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
214
|
+
const unit = getUnit(steps);
|
|
215
|
+
steps = steps.map(uikitUtil.toFloat);
|
|
231
216
|
|
|
232
|
-
|
|
233
|
-
|
|
217
|
+
if (!steps.some((step) => step)) {
|
|
218
|
+
return uikitUtil.noop;
|
|
219
|
+
}
|
|
234
220
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
221
|
+
const length = getMaxPathLength(el);
|
|
222
|
+
uikitUtil.css(el, 'strokeDasharray', length);
|
|
238
223
|
|
|
239
|
-
|
|
240
|
-
|
|
224
|
+
if (unit === '%') {
|
|
225
|
+
steps = steps.map((step) => step * length / 100);
|
|
226
|
+
}
|
|
241
227
|
|
|
242
|
-
|
|
243
|
-
steps = steps.map(function (step) { return step * length / 100; });
|
|
244
|
-
}
|
|
228
|
+
steps = steps.reverse();
|
|
245
229
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
css.strokeDashoffset = getValue(steps, percent);
|
|
250
|
-
};
|
|
230
|
+
return (css, percent) => {
|
|
231
|
+
css.strokeDashoffset = getValue(steps, percent);
|
|
232
|
+
};
|
|
251
233
|
}
|
|
252
234
|
|
|
253
235
|
function backgroundFn(prop, el, steps) {
|
|
236
|
+
if (steps.length === 1) {
|
|
237
|
+
steps.unshift(0);
|
|
238
|
+
}
|
|
254
239
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
prop = prop.substr(-1);
|
|
260
|
-
var attr = prop === 'y' ? 'height' : 'width';
|
|
261
|
-
steps = steps.map(function (step) { return uikitUtil.toPx(step, attr, el); });
|
|
240
|
+
prop = prop.substr(-1);
|
|
241
|
+
const attr = prop === 'y' ? 'height' : 'width';
|
|
242
|
+
steps = steps.map((step) => uikitUtil.toPx(step, attr, el));
|
|
262
243
|
|
|
263
|
-
|
|
264
|
-
var bgPos = uikitUtil.css(el, 'backgroundPosition').split(' ')[prop === 'x' ? 0 : 1]; // IE 11 can't read background-position-[x|y]
|
|
244
|
+
const bgPos = getCssValue(el, "background-position-" + prop, '');
|
|
265
245
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
246
|
+
return getCssValue(el, 'backgroundSize', '') === 'cover' ?
|
|
247
|
+
backgroundCoverFn(prop, el, steps, bgPos, attr) :
|
|
248
|
+
setBackgroundPosFn(prop, steps, bgPos);
|
|
269
249
|
}
|
|
270
250
|
|
|
271
251
|
function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
252
|
+
const dimImage = getBackgroundImageDimensions(el);
|
|
272
253
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
return uikitUtil.noop;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
var min = Math.min.apply(Math, steps);
|
|
280
|
-
var max = Math.max.apply(Math, steps);
|
|
281
|
-
var down = steps.indexOf(min) < steps.indexOf(max);
|
|
254
|
+
if (!dimImage.width) {
|
|
255
|
+
return uikitUtil.noop;
|
|
256
|
+
}
|
|
282
257
|
|
|
283
|
-
|
|
284
|
-
|
|
258
|
+
const min = Math.min(...steps);
|
|
259
|
+
const max = Math.max(...steps);
|
|
260
|
+
const down = steps.indexOf(min) < steps.indexOf(max);
|
|
285
261
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
height: el.offsetHeight
|
|
289
|
-
};
|
|
262
|
+
const diff = max - min;
|
|
263
|
+
let pos = (down ? -diff : 0) - (down ? min : max);
|
|
290
264
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
};
|
|
265
|
+
const dimEl = {
|
|
266
|
+
width: el.offsetWidth,
|
|
267
|
+
height: el.offsetHeight };
|
|
295
268
|
|
|
296
|
-
var baseDim = uikitUtil.Dimensions.cover(dimImage, dimEl);
|
|
297
|
-
var span = baseDim[attr] - dimEl[attr];
|
|
298
269
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
} else if (span > diff) {
|
|
270
|
+
const baseDim = uikitUtil.Dimensions.cover(dimImage, dimEl);
|
|
271
|
+
const span = baseDim[attr] - dimEl[attr];
|
|
302
272
|
|
|
303
|
-
|
|
273
|
+
if (span < diff) {
|
|
274
|
+
dimEl[attr] = baseDim[attr] + diff - span;
|
|
275
|
+
} else if (span > diff) {
|
|
276
|
+
const posPercentage = dimEl[attr] / uikitUtil.toPx(bgPos, attr, el, true);
|
|
304
277
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
278
|
+
if (posPercentage) {
|
|
279
|
+
pos -= (span - diff) / posPercentage;
|
|
308
280
|
}
|
|
281
|
+
}
|
|
309
282
|
|
|
310
|
-
|
|
283
|
+
const dim = uikitUtil.Dimensions.cover(dimImage, dimEl);
|
|
311
284
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
285
|
+
const fn = setBackgroundPosFn(prop, steps, pos + "px");
|
|
286
|
+
return (css, percent) => {
|
|
287
|
+
fn(css, percent);
|
|
288
|
+
css.backgroundSize = dim.width + "px " + dim.height + "px";
|
|
289
|
+
css.backgroundRepeat = 'no-repeat';
|
|
290
|
+
};
|
|
318
291
|
}
|
|
319
292
|
|
|
320
293
|
function setBackgroundPosFn(prop, steps, pos) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
294
|
+
return function (css, percent) {
|
|
295
|
+
css["background-position-" + prop] = "calc(" + pos + " + " + getValue(steps, percent) + "px)";
|
|
296
|
+
};
|
|
324
297
|
}
|
|
325
298
|
|
|
326
|
-
|
|
327
|
-
|
|
299
|
+
const dimensions = {};
|
|
300
|
+
function getBackgroundImageDimensions(el) {
|
|
301
|
+
const src = uikitUtil.css(el, 'backgroundImage').replace(/^none|url\(["']?(.+?)["']?\)$/, '$1');
|
|
328
302
|
|
|
329
|
-
|
|
303
|
+
if (dimensions[src]) {
|
|
304
|
+
return dimensions[src];
|
|
305
|
+
}
|
|
330
306
|
|
|
331
|
-
|
|
307
|
+
const image = new Image();
|
|
308
|
+
if (src) {
|
|
309
|
+
image.src = src;
|
|
332
310
|
|
|
333
|
-
if (
|
|
334
|
-
|
|
311
|
+
if (!image.naturalWidth) {
|
|
312
|
+
image.onload = () => {
|
|
313
|
+
dimensions[src] = toDimensions(image);
|
|
314
|
+
uikitUtil.trigger(el, 'bgimageload');
|
|
315
|
+
};
|
|
335
316
|
}
|
|
317
|
+
}
|
|
336
318
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
319
|
+
return dimensions[src] = toDimensions(image);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function toDimensions(image) {
|
|
323
|
+
return {
|
|
324
|
+
width: image.naturalWidth,
|
|
325
|
+
height: image.naturalHeight };
|
|
343
326
|
|
|
344
|
-
return data[src] = img;
|
|
345
|
-
}
|
|
346
327
|
}
|
|
347
328
|
|
|
348
329
|
function getStep(steps, percent) {
|
|
349
|
-
|
|
350
|
-
|
|
330
|
+
const count = steps.length - 1;
|
|
331
|
+
const index = Math.min(Math.floor(count * percent), count - 1);
|
|
351
332
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
333
|
+
return steps.
|
|
334
|
+
slice(index, index + 2).
|
|
335
|
+
concat(percent === 1 ? 1 : percent % (1 / count) * count);
|
|
355
336
|
}
|
|
356
337
|
|
|
357
338
|
function getValue(steps, percent) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
var end = ref[1];
|
|
361
|
-
var p = ref[2];
|
|
362
|
-
return uikitUtil.isNumber(start)
|
|
363
|
-
? start + Math.abs(start - end) * p * (start < end ? 1 : -1)
|
|
364
|
-
: +end;
|
|
339
|
+
const [start, end, p] = getStep(steps, percent);
|
|
340
|
+
return uikitUtil.isNumber(start) ? start + Math.abs(start - end) * p * (start < end ? 1 : -1) : +end;
|
|
365
341
|
}
|
|
366
342
|
|
|
367
343
|
function getUnit(steps, defaultUnit) {
|
|
368
|
-
|
|
344
|
+
return (
|
|
345
|
+
steps.reduce(
|
|
346
|
+
(unit, step) => unit || uikitUtil.isString(step) && step.replace(/[\d-]/g, '').trim(),
|
|
347
|
+
'') ||
|
|
348
|
+
defaultUnit);
|
|
349
|
+
|
|
369
350
|
}
|
|
370
351
|
|
|
371
352
|
function getCssValue(el, prop, value) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
353
|
+
const prev = el.style[prop];
|
|
354
|
+
const val = uikitUtil.css(uikitUtil.css(el, prop, value), prop);
|
|
355
|
+
el.style[prop] = prev;
|
|
356
|
+
return val;
|
|
376
357
|
}
|
|
377
358
|
|
|
378
359
|
function fillObject(keys, value) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
360
|
+
return keys.reduce((data, prop) => {
|
|
361
|
+
data[prop] = value;
|
|
362
|
+
return data;
|
|
363
|
+
}, {});
|
|
383
364
|
}
|
|
384
365
|
|
|
385
366
|
var Component = {
|
|
367
|
+
mixins: [Parallax],
|
|
386
368
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
start: String,
|
|
394
|
-
end: String
|
|
395
|
-
},
|
|
396
|
-
|
|
397
|
-
data: {
|
|
398
|
-
target: false,
|
|
399
|
-
viewport: 1,
|
|
400
|
-
easing: 1,
|
|
401
|
-
start: 0,
|
|
402
|
-
end: 0
|
|
403
|
-
},
|
|
404
|
-
|
|
405
|
-
computed: {
|
|
406
|
-
|
|
407
|
-
target: function(ref, $el) {
|
|
408
|
-
var target = ref.target;
|
|
409
|
-
|
|
410
|
-
return getOffsetElement(target && uikitUtil.query(target, $el) || $el);
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
start: function(ref) {
|
|
414
|
-
var start = ref.start;
|
|
369
|
+
props: {
|
|
370
|
+
target: String,
|
|
371
|
+
viewport: Number, // Deprecated
|
|
372
|
+
easing: Number,
|
|
373
|
+
start: String,
|
|
374
|
+
end: String },
|
|
415
375
|
|
|
416
|
-
return parseCalc(start, this.target);
|
|
417
|
-
},
|
|
418
376
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
377
|
+
data: {
|
|
378
|
+
target: false,
|
|
379
|
+
viewport: 1,
|
|
380
|
+
easing: 1,
|
|
381
|
+
start: 0,
|
|
382
|
+
end: 0 },
|
|
422
383
|
|
|
423
|
-
return parseCalc(
|
|
424
|
-
end || (viewport = (1 - viewport) * 100) && (viewport + "vh+" + viewport + "%"),
|
|
425
|
-
this.target
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
384
|
|
|
385
|
+
computed: {
|
|
386
|
+
target(_ref, $el) {let { target } = _ref;
|
|
387
|
+
return getOffsetElement(target && uikitUtil.query(target, $el) || $el);
|
|
429
388
|
},
|
|
430
389
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
var percent = ref.percent;
|
|
435
|
-
|
|
390
|
+
start(_ref2) {let { start } = _ref2;
|
|
391
|
+
return uikitUtil.toPx(start, 'height', this.target, true);
|
|
392
|
+
},
|
|
436
393
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
394
|
+
end(_ref3) {let { end, viewport } = _ref3;
|
|
395
|
+
return uikitUtil.toPx(
|
|
396
|
+
end || (viewport = (1 - viewport) * 100) && viewport + "vh+" + viewport + "%",
|
|
397
|
+
'height',
|
|
398
|
+
this.target,
|
|
399
|
+
true);
|
|
440
400
|
|
|
441
|
-
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
401
|
+
} },
|
|
444
402
|
|
|
445
|
-
var prev = percent;
|
|
446
|
-
percent = ease(uikitUtil.scrolledOver(this.target, this.start, this.end), this.easing);
|
|
447
403
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
404
|
+
update: {
|
|
405
|
+
read(_ref4, types) {let { percent } = _ref4;
|
|
406
|
+
if (!types.has('scroll')) {
|
|
407
|
+
percent = false;
|
|
408
|
+
}
|
|
453
409
|
|
|
454
|
-
|
|
455
|
-
|
|
410
|
+
if (!this.matchMedia) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
456
413
|
|
|
414
|
+
const prev = percent;
|
|
415
|
+
percent = ease(uikitUtil.scrolledOver(this.target, this.start, this.end), this.easing);
|
|
457
416
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}
|
|
417
|
+
return {
|
|
418
|
+
percent,
|
|
419
|
+
style: prev === percent ? false : this.getCss(percent) };
|
|
462
420
|
|
|
463
|
-
|
|
421
|
+
},
|
|
464
422
|
|
|
465
|
-
|
|
423
|
+
write(_ref5) {let { style } = _ref5;
|
|
424
|
+
if (!this.matchMedia) {
|
|
425
|
+
this.reset();
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
466
428
|
|
|
467
|
-
|
|
468
|
-
}
|
|
429
|
+
style && uikitUtil.css(this.$el, style);
|
|
430
|
+
},
|
|
469
431
|
|
|
470
|
-
|
|
432
|
+
events: ['scroll', 'resize'] } };
|
|
471
433
|
|
|
472
|
-
var calcRe = /-?\d+(?:\.\d+)?(?:v[wh]|%|px)?/g;
|
|
473
|
-
function parseCalc(calc, el) {
|
|
474
|
-
var match;
|
|
475
|
-
var result = 0;
|
|
476
|
-
calc = calc.toString().replace(/\s/g, '');
|
|
477
|
-
calcRe.lastIndex = 0;
|
|
478
|
-
while ((match = calcRe.exec(calc)) !== null) {
|
|
479
|
-
result += uikitUtil.toPx(match[0], 'height', el, true);
|
|
480
|
-
}
|
|
481
434
|
|
|
482
|
-
return result;
|
|
483
|
-
}
|
|
484
435
|
|
|
485
436
|
function ease(percent, easing) {
|
|
486
|
-
|
|
487
|
-
? Math.pow(percent, easing + 1)
|
|
488
|
-
: 1 - Math.pow(1 - percent, -easing + 1);
|
|
437
|
+
return easing >= 0 ? Math.pow(percent, easing + 1) : 1 - Math.pow(1 - percent, -easing + 1);
|
|
489
438
|
}
|
|
490
439
|
|
|
491
440
|
// SVG elements do not inherit from HTMLElement
|
|
492
441
|
function getOffsetElement(el) {
|
|
493
|
-
|
|
494
|
-
? 'offsetTop' in el
|
|
495
|
-
? el
|
|
496
|
-
: getOffsetElement(uikitUtil.parent(el))
|
|
497
|
-
: document.documentElement;
|
|
442
|
+
return el ? 'offsetTop' in el ? el : getOffsetElement(uikitUtil.parent(el)) : document.documentElement;
|
|
498
443
|
}
|
|
499
444
|
|
|
500
445
|
if (typeof window !== 'undefined' && window.UIkit) {
|
|
501
|
-
|
|
446
|
+
window.UIkit.component('parallax', Component);
|
|
502
447
|
}
|
|
503
448
|
|
|
504
449
|
return Component;
|