uikit 3.11.2-dev.31cd2ba38 → 3.11.2-dev.3dfa2c50b
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 +7 -11
- 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 -17
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +42 -17
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +42 -17
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +42 -17
- 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 +5266 -6572
- 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 +8126 -9876
- 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 +79 -100
- 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 +130 -105
- 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 +42 -47
- package/src/js/util/player.js +40 -36
- package/src/js/util/position.js +54 -46
- package/src/js/util/promise.js +0 -191
- package/src/js/util/selector.js +39 -48
- package/src/js/util/style.js +36 -46
- package/src/js/util/viewport.js +75 -64
- package/src/less/components/flex.less +0 -9
- package/src/less/components/navbar.less +0 -7
- package/src/less/components/utility.less +22 -0
- 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/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/image.html +38 -22
- package/tests/js/index.js +114 -85
- package/src/js/mixin/flex-bug.js +0 -56
- 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
|
+
isNumber,
|
|
8
|
+
isString,
|
|
9
|
+
isUndefined,
|
|
10
|
+
noop,
|
|
11
|
+
startsWith,
|
|
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,36 +53,34 @@ 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
82
|
function transformFn(prop, el, steps) {
|
|
73
|
-
|
|
74
|
-
const unit = getUnit(steps) || {x: 'px', y: 'px', rotate: 'deg'}[prop] || '';
|
|
83
|
+
const unit = getUnit(steps) || { x: 'px', y: 'px', rotate: 'deg' }[prop] || '';
|
|
75
84
|
|
|
76
85
|
if (prop === 'x' || prop === 'y') {
|
|
77
86
|
prop = `translate${ucfirst(prop)}`;
|
|
@@ -95,20 +104,20 @@ function transformFn(prop, el, steps) {
|
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
function colorFn(prop, el, steps) {
|
|
98
|
-
|
|
99
107
|
if (steps.length === 1) {
|
|
100
108
|
steps.unshift(getCssValue(el, prop, ''));
|
|
101
109
|
}
|
|
102
110
|
|
|
103
|
-
steps = steps.map(step => parseColor(el, step));
|
|
111
|
+
steps = steps.map((step) => parseColor(el, step));
|
|
104
112
|
|
|
105
113
|
return (css, percent) => {
|
|
106
|
-
|
|
107
114
|
const [start, end, p] = getStep(steps, percent);
|
|
108
|
-
const value = start
|
|
109
|
-
value
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
const value = start
|
|
116
|
+
.map((value, i) => {
|
|
117
|
+
value += p * (end[i] - value);
|
|
118
|
+
return i === 3 ? toFloat(value) : parseInt(value, 10);
|
|
119
|
+
})
|
|
120
|
+
.join(',');
|
|
112
121
|
css[prop] = `rgba(${value})`;
|
|
113
122
|
};
|
|
114
123
|
}
|
|
@@ -123,13 +132,12 @@ function parseColor(el, color) {
|
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
function filterFn(prop, el, steps) {
|
|
126
|
-
|
|
127
135
|
if (steps.length === 1) {
|
|
128
136
|
steps.unshift(0);
|
|
129
137
|
}
|
|
130
138
|
|
|
131
|
-
const unit = getUnit(steps) || {blur: 'px', hue: 'deg'}[prop] || '%';
|
|
132
|
-
prop = {fopacity: 'opacity', hue: 'hue-rotate'}[prop] || prop;
|
|
139
|
+
const unit = getUnit(steps) || { blur: 'px', hue: 'deg' }[prop] || '%';
|
|
140
|
+
prop = { fopacity: 'opacity', hue: 'hue-rotate' }[prop] || prop;
|
|
133
141
|
steps = steps.map(toFloat);
|
|
134
142
|
|
|
135
143
|
return (css, percent) => {
|
|
@@ -139,7 +147,6 @@ function filterFn(prop, el, steps) {
|
|
|
139
147
|
}
|
|
140
148
|
|
|
141
149
|
function cssPropFn(prop, el, steps) {
|
|
142
|
-
|
|
143
150
|
if (steps.length === 1) {
|
|
144
151
|
steps.unshift(getCssValue(el, prop, ''));
|
|
145
152
|
}
|
|
@@ -152,7 +159,6 @@ function cssPropFn(prop, el, steps) {
|
|
|
152
159
|
}
|
|
153
160
|
|
|
154
161
|
function strokeFn(prop, el, steps) {
|
|
155
|
-
|
|
156
162
|
if (steps.length === 1) {
|
|
157
163
|
steps.unshift(0);
|
|
158
164
|
}
|
|
@@ -160,7 +166,7 @@ function strokeFn(prop, el, steps) {
|
|
|
160
166
|
const unit = getUnit(steps);
|
|
161
167
|
steps = steps.map(toFloat);
|
|
162
168
|
|
|
163
|
-
if (!steps.some(step => step)) {
|
|
169
|
+
if (!steps.some((step) => step)) {
|
|
164
170
|
return noop;
|
|
165
171
|
}
|
|
166
172
|
|
|
@@ -168,7 +174,7 @@ function strokeFn(prop, el, steps) {
|
|
|
168
174
|
css(el, 'strokeDasharray', length);
|
|
169
175
|
|
|
170
176
|
if (unit === '%') {
|
|
171
|
-
steps = steps.map(step => step * length / 100);
|
|
177
|
+
steps = steps.map((step) => (step * length) / 100);
|
|
172
178
|
}
|
|
173
179
|
|
|
174
180
|
steps = steps.reverse();
|
|
@@ -179,17 +185,15 @@ function strokeFn(prop, el, steps) {
|
|
|
179
185
|
}
|
|
180
186
|
|
|
181
187
|
function backgroundFn(prop, el, steps) {
|
|
182
|
-
|
|
183
188
|
if (steps.length === 1) {
|
|
184
189
|
steps.unshift(0);
|
|
185
190
|
}
|
|
186
191
|
|
|
187
192
|
prop = prop.substr(-1);
|
|
188
193
|
const attr = prop === 'y' ? 'height' : 'width';
|
|
189
|
-
steps = steps.map(step => toPx(step, attr, el));
|
|
194
|
+
steps = steps.map((step) => toPx(step, attr, el));
|
|
190
195
|
|
|
191
|
-
|
|
192
|
-
const bgPos = css(el, 'backgroundPosition').split(' ')[prop === 'x' ? 0 : 1]; // IE 11 can't read background-position-[x|y]
|
|
196
|
+
const bgPos = getCssValue(el, `background-position-${prop}`, '');
|
|
193
197
|
|
|
194
198
|
return getCssValue(el, 'backgroundSize', '') === 'cover'
|
|
195
199
|
? backgroundCoverFn(prop, el, steps, bgPos, attr)
|
|
@@ -197,7 +201,6 @@ function backgroundFn(prop, el, steps) {
|
|
|
197
201
|
}
|
|
198
202
|
|
|
199
203
|
function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
200
|
-
|
|
201
204
|
const dimImage = getBackgroundImageDimensions(el);
|
|
202
205
|
|
|
203
206
|
if (!dimImage.width) {
|
|
@@ -213,7 +216,7 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
|
213
216
|
|
|
214
217
|
const dimEl = {
|
|
215
218
|
width: el.offsetWidth,
|
|
216
|
-
height: el.offsetHeight
|
|
219
|
+
height: el.offsetHeight,
|
|
217
220
|
};
|
|
218
221
|
|
|
219
222
|
const baseDim = Dimensions.cover(dimImage, dimEl);
|
|
@@ -222,7 +225,6 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
|
222
225
|
if (span < diff) {
|
|
223
226
|
dimEl[attr] = baseDim[attr] + diff - span;
|
|
224
227
|
} else if (span > diff) {
|
|
225
|
-
|
|
226
228
|
const posPercentage = dimEl[attr] / toPx(bgPos, attr, el, true);
|
|
227
229
|
|
|
228
230
|
if (posPercentage) {
|
|
@@ -266,13 +268,13 @@ function getBackgroundImageDimensions(el) {
|
|
|
266
268
|
}
|
|
267
269
|
}
|
|
268
270
|
|
|
269
|
-
return dimensions[src] = toDimensions(image);
|
|
271
|
+
return (dimensions[src] = toDimensions(image));
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
function toDimensions(image) {
|
|
273
275
|
return {
|
|
274
276
|
width: image.naturalWidth,
|
|
275
|
-
height: image.naturalHeight
|
|
277
|
+
height: image.naturalHeight,
|
|
276
278
|
};
|
|
277
279
|
}
|
|
278
280
|
|
|
@@ -282,18 +284,21 @@ function getStep(steps, percent) {
|
|
|
282
284
|
|
|
283
285
|
return steps
|
|
284
286
|
.slice(index, index + 2)
|
|
285
|
-
.concat(percent === 1 ? 1 : percent % (1 / count) * count);
|
|
287
|
+
.concat(percent === 1 ? 1 : (percent % (1 / count)) * count);
|
|
286
288
|
}
|
|
287
289
|
|
|
288
290
|
function getValue(steps, percent) {
|
|
289
291
|
const [start, end, p] = getStep(steps, percent);
|
|
290
|
-
return isNumber(start)
|
|
291
|
-
? start + Math.abs(start - end) * p * (start < end ? 1 : -1)
|
|
292
|
-
: +end;
|
|
292
|
+
return isNumber(start) ? start + Math.abs(start - end) * p * (start < end ? 1 : -1) : +end;
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
function getUnit(steps, defaultUnit) {
|
|
296
|
-
return
|
|
296
|
+
return (
|
|
297
|
+
steps.reduce(
|
|
298
|
+
(unit, step) => unit || (isString(step) && step.replace(/[\d-]/g, '').trim()),
|
|
299
|
+
''
|
|
300
|
+
) || defaultUnit
|
|
301
|
+
);
|
|
297
302
|
}
|
|
298
303
|
|
|
299
304
|
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
|
};
|
|
@@ -1,39 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
closest,
|
|
3
|
+
css,
|
|
4
|
+
getEventPos,
|
|
5
|
+
includes,
|
|
6
|
+
isRtl,
|
|
7
|
+
isTouch,
|
|
8
|
+
off,
|
|
9
|
+
on,
|
|
10
|
+
pointerCancel,
|
|
11
|
+
pointerDown,
|
|
12
|
+
pointerMove,
|
|
13
|
+
pointerUp,
|
|
14
|
+
selInput,
|
|
15
|
+
trigger,
|
|
16
|
+
} from 'uikit-util';
|
|
2
17
|
|
|
3
18
|
export default {
|
|
4
|
-
|
|
5
19
|
props: {
|
|
6
|
-
draggable: Boolean
|
|
20
|
+
draggable: Boolean,
|
|
7
21
|
},
|
|
8
22
|
|
|
9
23
|
data: {
|
|
10
24
|
draggable: true,
|
|
11
|
-
threshold: 10
|
|
25
|
+
threshold: 10,
|
|
12
26
|
},
|
|
13
27
|
|
|
14
28
|
created() {
|
|
15
|
-
|
|
16
|
-
['start', 'move', 'end'].forEach(key => {
|
|
17
|
-
|
|
29
|
+
for (const key of ['start', 'move', 'end']) {
|
|
18
30
|
const fn = this[key];
|
|
19
|
-
this[key] = e => {
|
|
20
|
-
|
|
31
|
+
this[key] = (e) => {
|
|
21
32
|
const pos = getEventPos(e).x * (isRtl ? -1 : 1);
|
|
22
33
|
|
|
23
|
-
this.prevPos = pos
|
|
34
|
+
this.prevPos = pos === this.pos ? this.prevPos : this.pos;
|
|
24
35
|
this.pos = pos;
|
|
25
36
|
|
|
26
37
|
fn(e);
|
|
27
38
|
};
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
|
|
39
|
+
}
|
|
31
40
|
},
|
|
32
41
|
|
|
33
42
|
events: [
|
|
34
|
-
|
|
35
43
|
{
|
|
36
|
-
|
|
37
44
|
name: pointerDown,
|
|
38
45
|
|
|
39
46
|
delegate() {
|
|
@@ -41,19 +48,18 @@ export default {
|
|
|
41
48
|
},
|
|
42
49
|
|
|
43
50
|
handler(e) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
if (
|
|
52
|
+
!this.draggable ||
|
|
53
|
+
(!isTouch(e) && hasTextNodesOnly(e.target)) ||
|
|
54
|
+
closest(e.target, selInput) ||
|
|
55
|
+
e.button > 0 ||
|
|
56
|
+
this.length < 2
|
|
50
57
|
) {
|
|
51
58
|
return;
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
this.start(e);
|
|
55
|
-
}
|
|
56
|
-
|
|
62
|
+
},
|
|
57
63
|
},
|
|
58
64
|
|
|
59
65
|
{
|
|
@@ -61,19 +67,15 @@ export default {
|
|
|
61
67
|
|
|
62
68
|
handler(e) {
|
|
63
69
|
e.preventDefault();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
70
|
+
},
|
|
71
|
+
},
|
|
67
72
|
],
|
|
68
73
|
|
|
69
74
|
methods: {
|
|
70
|
-
|
|
71
75
|
start() {
|
|
72
|
-
|
|
73
76
|
this.drag = this.pos;
|
|
74
77
|
|
|
75
78
|
if (this._transitioner) {
|
|
76
|
-
|
|
77
79
|
this.percent = this._transitioner.percent();
|
|
78
80
|
this.drag += this._transitioner.getDistance() * this.percent * this.dir;
|
|
79
81
|
|
|
@@ -83,25 +85,26 @@ export default {
|
|
|
83
85
|
this.dragging = true;
|
|
84
86
|
|
|
85
87
|
this.stack = [];
|
|
86
|
-
|
|
87
88
|
} else {
|
|
88
89
|
this.prevIndex = this.index;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
on(document, pointerMove, this.move, {passive: false});
|
|
92
|
+
on(document, pointerMove, this.move, { passive: false });
|
|
92
93
|
|
|
93
94
|
// 'input' event is triggered by video controls
|
|
94
95
|
on(document, `${pointerUp} ${pointerCancel} input`, this.end, true);
|
|
95
96
|
|
|
96
97
|
css(this.list, 'userSelect', 'none');
|
|
97
|
-
|
|
98
98
|
},
|
|
99
99
|
|
|
100
100
|
move(e) {
|
|
101
|
-
|
|
102
101
|
const distance = this.pos - this.drag;
|
|
103
102
|
|
|
104
|
-
if (
|
|
103
|
+
if (
|
|
104
|
+
distance === 0 ||
|
|
105
|
+
this.prevPos === this.pos ||
|
|
106
|
+
(!this.dragging && Math.abs(distance) < this.threshold)
|
|
107
|
+
) {
|
|
105
108
|
return;
|
|
106
109
|
}
|
|
107
110
|
|
|
@@ -111,23 +114,21 @@ export default {
|
|
|
111
114
|
e.cancelable && e.preventDefault();
|
|
112
115
|
|
|
113
116
|
this.dragging = true;
|
|
114
|
-
this.dir =
|
|
117
|
+
this.dir = distance < 0 ? 1 : -1;
|
|
115
118
|
|
|
116
|
-
const {slides} = this;
|
|
117
|
-
let {prevIndex} = this;
|
|
119
|
+
const { slides } = this;
|
|
120
|
+
let { prevIndex } = this;
|
|
118
121
|
let dis = Math.abs(distance);
|
|
119
122
|
let nextIndex = this.getIndex(prevIndex + this.dir, prevIndex);
|
|
120
123
|
let width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth;
|
|
121
124
|
|
|
122
125
|
while (nextIndex !== prevIndex && dis > width) {
|
|
123
|
-
|
|
124
126
|
this.drag -= width * this.dir;
|
|
125
127
|
|
|
126
128
|
prevIndex = nextIndex;
|
|
127
129
|
dis -= width;
|
|
128
130
|
nextIndex = this.getIndex(prevIndex + this.dir, prevIndex);
|
|
129
131
|
width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth;
|
|
130
|
-
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
this.percent = dis / width;
|
|
@@ -139,17 +140,18 @@ export default {
|
|
|
139
140
|
|
|
140
141
|
let itemShown;
|
|
141
142
|
|
|
142
|
-
[this.index, this.prevIndex]
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
itemShown = true;
|
|
147
|
-
this.prevIndex = prevIndex;
|
|
148
|
-
}
|
|
143
|
+
[this.index, this.prevIndex]
|
|
144
|
+
.filter((i) => !includes([nextIndex, prevIndex], i))
|
|
145
|
+
.forEach((i) => {
|
|
146
|
+
trigger(slides[i], 'itemhidden', [this]);
|
|
149
147
|
|
|
150
|
-
|
|
148
|
+
if (edge) {
|
|
149
|
+
itemShown = true;
|
|
150
|
+
this.prevIndex = prevIndex;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
151
153
|
|
|
152
|
-
if (this.index === prevIndex && this.prevIndex !== prevIndex || itemShown) {
|
|
154
|
+
if ((this.index === prevIndex && this.prevIndex !== prevIndex) || itemShown) {
|
|
153
155
|
trigger(slides[this.index], 'itemshown', [this]);
|
|
154
156
|
}
|
|
155
157
|
|
|
@@ -167,16 +169,13 @@ export default {
|
|
|
167
169
|
!edge && trigger(prev, 'itemhide', [this]);
|
|
168
170
|
trigger(next, 'itemshow', [this]);
|
|
169
171
|
}
|
|
170
|
-
|
|
171
172
|
},
|
|
172
173
|
|
|
173
174
|
end() {
|
|
174
|
-
|
|
175
|
-
off(document, pointerMove, this.move, {passive: false});
|
|
175
|
+
off(document, pointerMove, this.move, { passive: false });
|
|
176
176
|
off(document, `${pointerUp} ${pointerCancel} input`, this.end, true);
|
|
177
177
|
|
|
178
178
|
if (this.dragging) {
|
|
179
|
-
|
|
180
179
|
this.dragging = null;
|
|
181
180
|
|
|
182
181
|
if (this.index === this.prevIndex) {
|
|
@@ -185,29 +184,29 @@ export default {
|
|
|
185
184
|
this._show(false, this.index, true);
|
|
186
185
|
this._transitioner = null;
|
|
187
186
|
} else {
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
const dirChange =
|
|
188
|
+
(isRtl ? this.dir * (isRtl ? 1 : -1) : this.dir) < 0 ===
|
|
189
|
+
this.prevPos > this.pos;
|
|
190
190
|
this.index = dirChange ? this.index : this.prevIndex;
|
|
191
191
|
|
|
192
192
|
if (dirChange) {
|
|
193
193
|
this.percent = 1 - this.percent;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
this.show(
|
|
196
|
+
this.show(
|
|
197
|
+
(this.dir > 0 && !dirChange) || (this.dir < 0 && dirChange)
|
|
198
|
+
? 'next'
|
|
199
|
+
: 'previous',
|
|
200
|
+
true
|
|
201
|
+
);
|
|
197
202
|
}
|
|
198
|
-
|
|
199
203
|
}
|
|
200
204
|
|
|
201
|
-
css(this.list, {userSelect: '', pointerEvents: ''});
|
|
202
|
-
|
|
203
|
-
this.drag
|
|
204
|
-
= this.percent
|
|
205
|
-
= null;
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
}
|
|
205
|
+
css(this.list, { userSelect: '', pointerEvents: '' });
|
|
210
206
|
|
|
207
|
+
this.drag = this.percent = null;
|
|
208
|
+
},
|
|
209
|
+
},
|
|
211
210
|
};
|
|
212
211
|
|
|
213
212
|
function hasTextNodesOnly(el) {
|