uikit 3.11.2-dev.31cd2ba38 → 3.11.2-dev.4274bc35b
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 +38 -28
- 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 +121 -202
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +121 -202
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +123 -208
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +123 -208
- 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 +326 -358
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +324 -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 +324 -357
- 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 -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 +5405 -6716
- 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 +7997 -9703
- 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 +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 -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 +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 +38 -50
- package/src/js/core/img.js +127 -87
- 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 +130 -91
- 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 +130 -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 +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 +56 -43
- package/src/js/util/dom.js +44 -80
- 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 +33 -47
- 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 +52 -97
- package/src/less/components/form.less +0 -1
- 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 +52 -97
- package/src/scss/components/form.scss +3 -4
- 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 -48
- 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 +47 -62
- 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/mixin/parallax.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import Media from '../mixin/media';
|
|
2
|
-
import {getMaxPathLength} from '../core/svg';
|
|
3
|
-
import {
|
|
2
|
+
import { getMaxPathLength } from '../core/svg';
|
|
3
|
+
import {
|
|
4
|
+
css,
|
|
5
|
+
Dimensions,
|
|
6
|
+
each,
|
|
7
|
+
findIndex,
|
|
8
|
+
isNumber,
|
|
9
|
+
isString,
|
|
10
|
+
isUndefined,
|
|
11
|
+
noop,
|
|
12
|
+
toFloat,
|
|
13
|
+
toPx,
|
|
14
|
+
trigger,
|
|
15
|
+
ucfirst,
|
|
16
|
+
} from 'uikit-util';
|
|
4
17
|
|
|
5
18
|
const props = {
|
|
6
19
|
x: transformFn,
|
|
@@ -20,13 +33,12 @@ const props = {
|
|
|
20
33
|
opacity: cssPropFn,
|
|
21
34
|
stroke: strokeFn,
|
|
22
35
|
bgx: backgroundFn,
|
|
23
|
-
bgy: backgroundFn
|
|
36
|
+
bgy: backgroundFn,
|
|
24
37
|
};
|
|
25
38
|
|
|
26
|
-
const {keys} = Object;
|
|
39
|
+
const { keys } = Object;
|
|
27
40
|
|
|
28
41
|
export default {
|
|
29
|
-
|
|
30
42
|
mixins: [Media],
|
|
31
43
|
|
|
32
44
|
props: fillObject(keys(props), 'list'),
|
|
@@ -34,7 +46,6 @@ export default {
|
|
|
34
46
|
data: fillObject(keys(props), undefined),
|
|
35
47
|
|
|
36
48
|
computed: {
|
|
37
|
-
|
|
38
49
|
props(properties, $el) {
|
|
39
50
|
return keys(props).reduce((result, prop) => {
|
|
40
51
|
if (!isUndefined(properties[prop])) {
|
|
@@ -42,73 +53,67 @@ export default {
|
|
|
42
53
|
}
|
|
43
54
|
return result;
|
|
44
55
|
}, {});
|
|
45
|
-
}
|
|
46
|
-
|
|
56
|
+
},
|
|
47
57
|
},
|
|
48
58
|
|
|
49
59
|
events: {
|
|
50
60
|
bgimageload() {
|
|
51
61
|
this.$emit();
|
|
52
|
-
}
|
|
62
|
+
},
|
|
53
63
|
},
|
|
54
64
|
|
|
55
65
|
methods: {
|
|
56
|
-
|
|
57
66
|
reset() {
|
|
58
67
|
each(this.getCss(0), (_, prop) => css(this.$el, prop, ''));
|
|
59
68
|
},
|
|
60
69
|
|
|
61
70
|
getCss(percent) {
|
|
62
|
-
return keys(this.props).reduce(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
return keys(this.props).reduce(
|
|
72
|
+
(css, prop) => {
|
|
73
|
+
this.props[prop](css, percent);
|
|
74
|
+
return css;
|
|
75
|
+
},
|
|
76
|
+
{ transform: '', filter: '' }
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
70
80
|
};
|
|
71
81
|
|
|
72
|
-
function transformFn(prop, el,
|
|
73
|
-
|
|
74
|
-
|
|
82
|
+
function transformFn(prop, el, stops) {
|
|
83
|
+
const unit = getUnit(stops) || { x: 'px', y: 'px', rotate: 'deg' }[prop] || '';
|
|
84
|
+
let transformFn;
|
|
75
85
|
|
|
76
86
|
if (prop === 'x' || prop === 'y') {
|
|
77
87
|
prop = `translate${ucfirst(prop)}`;
|
|
88
|
+
transformFn = (stop) => toFloat(toFloat(stop).toFixed(unit === 'px' ? 0 : 6));
|
|
78
89
|
}
|
|
79
90
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (steps.length === 1) {
|
|
83
|
-
steps.unshift(prop === 'scale' ? 1 : 0);
|
|
91
|
+
if (stops.length === 1) {
|
|
92
|
+
stops.unshift(prop === 'scale' ? 1 : 0);
|
|
84
93
|
}
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
let value = getValue(steps, percent);
|
|
88
|
-
|
|
89
|
-
if (startsWith(prop, 'translate')) {
|
|
90
|
-
value = toFloat(value).toFixed(unit === 'px' ? 0 : 6);
|
|
91
|
-
}
|
|
95
|
+
stops = parseStops(stops, transformFn);
|
|
92
96
|
|
|
93
|
-
|
|
97
|
+
return (css, percent) => {
|
|
98
|
+
css.transform += ` ${prop}(${getValue(stops, percent)}${unit})`;
|
|
94
99
|
};
|
|
95
100
|
}
|
|
96
101
|
|
|
97
|
-
function colorFn(prop, el,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
steps.unshift(getCssValue(el, prop, ''));
|
|
102
|
+
function colorFn(prop, el, stops) {
|
|
103
|
+
if (stops.length === 1) {
|
|
104
|
+
stops.unshift(getCssValue(el, prop, ''));
|
|
101
105
|
}
|
|
102
106
|
|
|
103
|
-
|
|
107
|
+
stops = parseStops(stops, (stop) => parseColor(el, stop));
|
|
104
108
|
|
|
105
109
|
return (css, percent) => {
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
const [start, end, p] = getStop(stops, percent);
|
|
111
|
+
const value = start
|
|
112
|
+
.map((value, i) => {
|
|
113
|
+
value += p * (end[i] - value);
|
|
114
|
+
return i === 3 ? toFloat(value) : parseInt(value, 10);
|
|
115
|
+
})
|
|
116
|
+
.join(',');
|
|
112
117
|
css[prop] = `rgba(${value})`;
|
|
113
118
|
};
|
|
114
119
|
}
|
|
@@ -122,98 +127,90 @@ function parseColor(el, color) {
|
|
|
122
127
|
.map(toFloat);
|
|
123
128
|
}
|
|
124
129
|
|
|
125
|
-
function filterFn(prop, el,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
steps.unshift(0);
|
|
130
|
+
function filterFn(prop, el, stops) {
|
|
131
|
+
if (stops.length === 1) {
|
|
132
|
+
stops.unshift(0);
|
|
129
133
|
}
|
|
130
134
|
|
|
131
|
-
const unit = getUnit(
|
|
132
|
-
prop = {fopacity: 'opacity', hue: 'hue-rotate'}[prop] || prop;
|
|
133
|
-
|
|
135
|
+
const unit = getUnit(stops) || { blur: 'px', hue: 'deg' }[prop] || '%';
|
|
136
|
+
prop = { fopacity: 'opacity', hue: 'hue-rotate' }[prop] || prop;
|
|
137
|
+
stops = parseStops(stops);
|
|
134
138
|
|
|
135
139
|
return (css, percent) => {
|
|
136
|
-
const value = getValue(
|
|
140
|
+
const value = getValue(stops, percent);
|
|
137
141
|
css.filter += ` ${prop}(${value + unit})`;
|
|
138
142
|
};
|
|
139
143
|
}
|
|
140
144
|
|
|
141
|
-
function cssPropFn(prop, el,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
steps.unshift(getCssValue(el, prop, ''));
|
|
145
|
+
function cssPropFn(prop, el, stops) {
|
|
146
|
+
if (stops.length === 1) {
|
|
147
|
+
stops.unshift(getCssValue(el, prop, ''));
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
|
|
150
|
+
stops = parseStops(stops);
|
|
148
151
|
|
|
149
152
|
return (css, percent) => {
|
|
150
|
-
css[prop] = getValue(
|
|
153
|
+
css[prop] = getValue(stops, percent);
|
|
151
154
|
};
|
|
152
155
|
}
|
|
153
156
|
|
|
154
|
-
function strokeFn(prop, el,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
steps.unshift(0);
|
|
157
|
+
function strokeFn(prop, el, stops) {
|
|
158
|
+
if (stops.length === 1) {
|
|
159
|
+
stops.unshift(0);
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
const unit = getUnit(
|
|
161
|
-
|
|
162
|
+
const unit = getUnit(stops);
|
|
163
|
+
const length = getMaxPathLength(el);
|
|
164
|
+
stops = parseStops(stops.reverse(), (stop) => {
|
|
165
|
+
stop = toFloat(stop);
|
|
166
|
+
return unit === '%' ? (stop * length) / 100 : stop;
|
|
167
|
+
});
|
|
162
168
|
|
|
163
|
-
if (!
|
|
169
|
+
if (!stops.some(([value]) => value)) {
|
|
164
170
|
return noop;
|
|
165
171
|
}
|
|
166
172
|
|
|
167
|
-
const length = getMaxPathLength(el);
|
|
168
173
|
css(el, 'strokeDasharray', length);
|
|
169
174
|
|
|
170
|
-
if (unit === '%') {
|
|
171
|
-
steps = steps.map(step => step * length / 100);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
steps = steps.reverse();
|
|
175
|
-
|
|
176
175
|
return (css, percent) => {
|
|
177
|
-
css.strokeDashoffset = getValue(
|
|
176
|
+
css.strokeDashoffset = getValue(stops, percent);
|
|
178
177
|
};
|
|
179
178
|
}
|
|
180
179
|
|
|
181
|
-
function backgroundFn(prop, el,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
steps.unshift(0);
|
|
180
|
+
function backgroundFn(prop, el, stops) {
|
|
181
|
+
if (stops.length === 1) {
|
|
182
|
+
stops.unshift(0);
|
|
185
183
|
}
|
|
186
184
|
|
|
187
185
|
prop = prop.substr(-1);
|
|
188
186
|
const attr = prop === 'y' ? 'height' : 'width';
|
|
189
|
-
|
|
187
|
+
stops = parseStops(stops, (stop) => toPx(stop, attr, el));
|
|
190
188
|
|
|
191
|
-
|
|
192
|
-
const bgPos = css(el, 'backgroundPosition').split(' ')[prop === 'x' ? 0 : 1]; // IE 11 can't read background-position-[x|y]
|
|
189
|
+
const bgPos = getCssValue(el, `background-position-${prop}`, '');
|
|
193
190
|
|
|
194
191
|
return getCssValue(el, 'backgroundSize', '') === 'cover'
|
|
195
|
-
? backgroundCoverFn(prop, el,
|
|
196
|
-
: setBackgroundPosFn(prop,
|
|
192
|
+
? backgroundCoverFn(prop, el, stops, bgPos, attr)
|
|
193
|
+
: setBackgroundPosFn(prop, stops, bgPos);
|
|
197
194
|
}
|
|
198
195
|
|
|
199
|
-
function backgroundCoverFn(prop, el,
|
|
200
|
-
|
|
196
|
+
function backgroundCoverFn(prop, el, stops, bgPos, attr) {
|
|
201
197
|
const dimImage = getBackgroundImageDimensions(el);
|
|
202
198
|
|
|
203
199
|
if (!dimImage.width) {
|
|
204
200
|
return noop;
|
|
205
201
|
}
|
|
206
202
|
|
|
207
|
-
const
|
|
208
|
-
const
|
|
209
|
-
const
|
|
203
|
+
const values = stops.map(([value]) => value);
|
|
204
|
+
const min = Math.min(...values);
|
|
205
|
+
const max = Math.max(...values);
|
|
206
|
+
const down = values.indexOf(min) < values.indexOf(max);
|
|
210
207
|
|
|
211
208
|
const diff = max - min;
|
|
212
209
|
let pos = (down ? -diff : 0) - (down ? min : max);
|
|
213
210
|
|
|
214
211
|
const dimEl = {
|
|
215
212
|
width: el.offsetWidth,
|
|
216
|
-
height: el.offsetHeight
|
|
213
|
+
height: el.offsetHeight,
|
|
217
214
|
};
|
|
218
215
|
|
|
219
216
|
const baseDim = Dimensions.cover(dimImage, dimEl);
|
|
@@ -222,7 +219,6 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
|
222
219
|
if (span < diff) {
|
|
223
220
|
dimEl[attr] = baseDim[attr] + diff - span;
|
|
224
221
|
} else if (span > diff) {
|
|
225
|
-
|
|
226
222
|
const posPercentage = dimEl[attr] / toPx(bgPos, attr, el, true);
|
|
227
223
|
|
|
228
224
|
if (posPercentage) {
|
|
@@ -232,7 +228,7 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
|
232
228
|
|
|
233
229
|
const dim = Dimensions.cover(dimImage, dimEl);
|
|
234
230
|
|
|
235
|
-
const fn = setBackgroundPosFn(prop,
|
|
231
|
+
const fn = setBackgroundPosFn(prop, stops, `${pos}px`);
|
|
236
232
|
return (css, percent) => {
|
|
237
233
|
fn(css, percent);
|
|
238
234
|
css.backgroundSize = `${dim.width}px ${dim.height}px`;
|
|
@@ -240,9 +236,9 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
|
240
236
|
};
|
|
241
237
|
}
|
|
242
238
|
|
|
243
|
-
function setBackgroundPosFn(prop,
|
|
239
|
+
function setBackgroundPosFn(prop, stops, pos) {
|
|
244
240
|
return function (css, percent) {
|
|
245
|
-
css[`background-position-${prop}`] = `calc(${pos} + ${getValue(
|
|
241
|
+
css[`background-position-${prop}`] = `calc(${pos} + ${getValue(stops, percent)}px)`;
|
|
246
242
|
};
|
|
247
243
|
}
|
|
248
244
|
|
|
@@ -266,34 +262,62 @@ function getBackgroundImageDimensions(el) {
|
|
|
266
262
|
}
|
|
267
263
|
}
|
|
268
264
|
|
|
269
|
-
return dimensions[src] = toDimensions(image);
|
|
265
|
+
return (dimensions[src] = toDimensions(image));
|
|
270
266
|
}
|
|
271
267
|
|
|
272
268
|
function toDimensions(image) {
|
|
273
269
|
return {
|
|
274
270
|
width: image.naturalWidth,
|
|
275
|
-
height: image.naturalHeight
|
|
271
|
+
height: image.naturalHeight,
|
|
276
272
|
};
|
|
277
273
|
}
|
|
278
274
|
|
|
279
|
-
function
|
|
280
|
-
const
|
|
281
|
-
const
|
|
275
|
+
function parseStops(stops, fn = toFloat) {
|
|
276
|
+
const result = [];
|
|
277
|
+
for (const stop of stops) {
|
|
278
|
+
const [value, percent] = isString(stop) ? stop.trim().split(' ') : [stop];
|
|
279
|
+
result.push([fn(value), percent ? toFloat(percent) / 100 : null]);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const { length } = result;
|
|
283
|
+
result[0][1] = 0;
|
|
284
|
+
result[length - 1][1] = 1;
|
|
285
|
+
for (let i = 1; i < length - 1; i++) {
|
|
286
|
+
if (result[i] === null) {
|
|
287
|
+
const nextIndex = findIndex(result.slice(i + 1), ([, percent]) => percent !== null) + 1;
|
|
288
|
+
const percent = (result[i + nextIndex] - result[i - 1][1]) / (nextIndex + 1);
|
|
289
|
+
for (let j = 0; j < nextIndex; j++) {
|
|
290
|
+
result[i + j][1] = percent * j + 1;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
282
297
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
298
|
+
function getStop(stops, percent) {
|
|
299
|
+
const index = findIndex(stops.slice(1), ([, targetPercent]) => percent <= targetPercent) + 1;
|
|
300
|
+
return [
|
|
301
|
+
stops[index - 1][0],
|
|
302
|
+
stops[index][0],
|
|
303
|
+
(percent - stops[index - 1][1]) / (stops[index][1] - stops[index - 1][1]),
|
|
304
|
+
];
|
|
286
305
|
}
|
|
287
306
|
|
|
288
|
-
function getValue(
|
|
289
|
-
const [start, end, p] =
|
|
290
|
-
return isNumber(start)
|
|
291
|
-
? start + Math.abs(start - end) * p * (start < end ? 1 : -1)
|
|
292
|
-
: +end;
|
|
307
|
+
function getValue(stops, percent) {
|
|
308
|
+
const [start, end, p] = getStop(stops, percent);
|
|
309
|
+
return isNumber(start) ? start + Math.abs(start - end) * p * (start < end ? 1 : -1) : +end;
|
|
293
310
|
}
|
|
294
311
|
|
|
295
|
-
|
|
296
|
-
|
|
312
|
+
const unitRe = /^[\d-]+([^\s]+)/;
|
|
313
|
+
function getUnit(stops, defaultUnit) {
|
|
314
|
+
for (const stop of stops) {
|
|
315
|
+
const match = stop.match?.(unitRe);
|
|
316
|
+
if (match) {
|
|
317
|
+
return match[1];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return defaultUnit;
|
|
297
321
|
}
|
|
298
322
|
|
|
299
323
|
function getCssValue(el, prop, value) {
|
package/src/js/mixin/position.js
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
$,
|
|
3
|
+
flipPosition,
|
|
4
|
+
offset as getOffset,
|
|
5
|
+
isNumeric,
|
|
6
|
+
isRtl,
|
|
7
|
+
positionAt,
|
|
8
|
+
removeClasses,
|
|
9
|
+
toggleClass,
|
|
10
|
+
} from 'uikit-util';
|
|
2
11
|
|
|
3
12
|
export default {
|
|
4
|
-
|
|
5
13
|
props: {
|
|
6
14
|
pos: String,
|
|
7
15
|
offset: null,
|
|
8
16
|
flip: Boolean,
|
|
9
|
-
clsPos: String
|
|
17
|
+
clsPos: String,
|
|
10
18
|
},
|
|
11
19
|
|
|
12
20
|
data: {
|
|
13
21
|
pos: `bottom-${isRtl ? 'right' : 'left'}`,
|
|
14
22
|
flip: true,
|
|
15
23
|
offset: false,
|
|
16
|
-
clsPos: ''
|
|
24
|
+
clsPos: '',
|
|
17
25
|
},
|
|
18
26
|
|
|
19
27
|
computed: {
|
|
20
|
-
|
|
21
|
-
pos({pos}) {
|
|
28
|
+
pos({ pos }) {
|
|
22
29
|
return pos.split('-').concat('center').slice(0, 2);
|
|
23
30
|
},
|
|
24
31
|
|
|
@@ -28,32 +35,34 @@ export default {
|
|
|
28
35
|
|
|
29
36
|
align() {
|
|
30
37
|
return this.pos[1];
|
|
31
|
-
}
|
|
32
|
-
|
|
38
|
+
},
|
|
33
39
|
},
|
|
34
40
|
|
|
35
41
|
methods: {
|
|
36
|
-
|
|
37
42
|
positionAt(element, target, boundary) {
|
|
38
|
-
|
|
39
43
|
removeClasses(element, `${this.clsPos}-(top|bottom|left|right)(-[a-z]+)?`);
|
|
40
44
|
|
|
41
|
-
let {offset} = this;
|
|
45
|
+
let { offset } = this;
|
|
42
46
|
const axis = this.getAxis();
|
|
43
47
|
|
|
44
48
|
if (!isNumeric(offset)) {
|
|
45
49
|
const node = $(offset);
|
|
46
50
|
offset = node
|
|
47
|
-
? getOffset(node)[axis === 'x' ? 'left' : 'top'] -
|
|
51
|
+
? getOffset(node)[axis === 'x' ? 'left' : 'top'] -
|
|
52
|
+
getOffset(target)[axis === 'x' ? 'right' : 'bottom']
|
|
48
53
|
: 0;
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
const {x, y} = positionAt(
|
|
56
|
+
const { x, y } = positionAt(
|
|
52
57
|
element,
|
|
53
58
|
target,
|
|
54
|
-
axis === 'x'
|
|
59
|
+
axis === 'x'
|
|
60
|
+
? `${flipPosition(this.dir)} ${this.align}`
|
|
61
|
+
: `${this.align} ${flipPosition(this.dir)}`,
|
|
55
62
|
axis === 'x' ? `${this.dir} ${this.align}` : `${this.align} ${this.dir}`,
|
|
56
|
-
axis === 'x'
|
|
63
|
+
axis === 'x'
|
|
64
|
+
? `${this.dir === 'left' ? -offset : offset}`
|
|
65
|
+
: ` ${this.dir === 'top' ? -offset : offset}`,
|
|
57
66
|
null,
|
|
58
67
|
this.flip,
|
|
59
68
|
boundary
|
|
@@ -63,13 +72,10 @@ export default {
|
|
|
63
72
|
this.align = axis === 'x' ? y : x;
|
|
64
73
|
|
|
65
74
|
toggleClass(element, `${this.clsPos}-${this.dir}-${this.align}`, this.offset === false);
|
|
66
|
-
|
|
67
75
|
},
|
|
68
76
|
|
|
69
77
|
getAxis() {
|
|
70
78
|
return this.dir === 'top' || this.dir === 'bottom' ? 'y' : 'x';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
79
|
+
},
|
|
80
|
+
},
|
|
75
81
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {$, attr, matches} from 'uikit-util';
|
|
1
|
+
import { $, attr, matches } from 'uikit-util';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
|
|
5
4
|
props: {
|
|
6
5
|
autoplay: Boolean,
|
|
7
6
|
autoplayInterval: Number,
|
|
8
|
-
pauseOnHover: Boolean
|
|
7
|
+
pauseOnHover: Boolean,
|
|
9
8
|
},
|
|
10
9
|
|
|
11
10
|
data: {
|
|
12
11
|
autoplay: false,
|
|
13
12
|
autoplayInterval: 7000,
|
|
14
|
-
pauseOnHover: true
|
|
13
|
+
pauseOnHover: true,
|
|
15
14
|
},
|
|
16
15
|
|
|
17
16
|
connected() {
|
|
@@ -27,9 +26,7 @@ export default {
|
|
|
27
26
|
},
|
|
28
27
|
|
|
29
28
|
events: [
|
|
30
|
-
|
|
31
29
|
{
|
|
32
|
-
|
|
33
30
|
name: 'visibilitychange',
|
|
34
31
|
|
|
35
32
|
el() {
|
|
@@ -46,32 +43,26 @@ export default {
|
|
|
46
43
|
} else {
|
|
47
44
|
this.startAutoplay();
|
|
48
45
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
46
|
+
},
|
|
47
|
+
},
|
|
53
48
|
],
|
|
54
49
|
|
|
55
50
|
methods: {
|
|
56
|
-
|
|
57
51
|
startAutoplay() {
|
|
58
|
-
|
|
59
52
|
this.stopAutoplay();
|
|
60
53
|
|
|
61
54
|
this.interval = setInterval(
|
|
62
|
-
() =>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
() =>
|
|
56
|
+
(!this.draggable || !$(':focus', this.$el)) &&
|
|
57
|
+
(!this.pauseOnHover || !matches(this.$el, ':hover')) &&
|
|
58
|
+
!this.stack.length &&
|
|
59
|
+
this.show('next'),
|
|
66
60
|
this.autoplayInterval
|
|
67
61
|
);
|
|
68
|
-
|
|
69
62
|
},
|
|
70
63
|
|
|
71
64
|
stopAutoplay() {
|
|
72
65
|
this.interval && clearInterval(this.interval);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
66
|
+
},
|
|
67
|
+
},
|
|
77
68
|
};
|