uikit 3.11.2-dev.44c622843 → 3.11.2-dev.536e1a374
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/CHANGELOG.md +40 -19
- package/dist/css/uikit-core-rtl.css +97 -190
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +97 -190
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +99 -196
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +99 -196
- package/dist/css/uikit.min.css +1 -1
- package/dist/js/components/countdown.js +24 -51
- package/dist/js/components/countdown.min.js +1 -1
- package/dist/js/components/filter.js +6 -8
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +30 -69
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +31 -71
- package/dist/js/components/lightbox.min.js +1 -1
- package/dist/js/components/notification.js +1 -1
- package/dist/js/components/notification.min.js +1 -1
- package/dist/js/components/parallax.js +117 -80
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +117 -80
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +87 -58
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +117 -80
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +43 -29
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +5 -7
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +3 -3
- package/dist/js/components/tooltip.min.js +1 -1
- package/dist/js/components/upload.js +2 -1
- package/dist/js/components/upload.min.js +1 -1
- package/dist/js/uikit-core.js +600 -508
- package/dist/js/uikit-core.min.js +1 -1
- package/dist/js/uikit-icons.js +1 -1
- package/dist/js/uikit-icons.min.js +1 -1
- package/dist/js/uikit.js +857 -764
- package/dist/js/uikit.min.js +1 -1
- package/package.json +1 -1
- package/src/js/api/component.js +2 -11
- package/src/js/api/hooks.js +3 -3
- package/src/js/api/state.js +173 -140
- package/src/js/components/countdown.js +24 -51
- package/src/js/components/filter.js +2 -3
- package/src/js/components/internal/lightbox-animations.js +4 -3
- package/src/js/components/internal/slider-preload.js +9 -0
- package/src/js/components/internal/slideshow-animations.js +4 -3
- package/src/js/components/lightbox-panel.js +34 -58
- package/src/js/components/lightbox.js +1 -2
- package/src/js/components/slider.js +60 -43
- package/src/js/components/slideshow.js +8 -1
- package/src/js/components/sortable.js +1 -1
- package/src/js/components/upload.js +2 -1
- package/src/js/core/accordion.js +6 -1
- package/src/js/core/alert.js +1 -2
- package/src/js/core/core.js +2 -75
- package/src/js/core/cover.js +5 -1
- package/src/js/core/drop.js +3 -1
- package/src/js/core/form-custom.js +2 -2
- package/src/js/core/height-viewport.js +3 -0
- package/src/js/core/icon.js +13 -6
- package/src/js/core/img.js +131 -122
- package/src/js/core/modal.js +1 -2
- package/src/js/core/navbar.js +3 -3
- package/src/js/core/offcanvas.js +2 -1
- package/src/js/core/sticky.js +51 -57
- package/src/js/core/svg.js +10 -6
- package/src/js/core/switcher.js +11 -3
- package/src/js/core/toggle.js +5 -2
- package/src/js/core/video.js +13 -1
- package/src/js/mixin/internal/animate-slide.js +9 -12
- package/src/js/mixin/lazyload.js +20 -0
- package/src/js/mixin/parallax.js +118 -81
- package/src/js/mixin/slider.js +8 -22
- package/src/js/mixin/slideshow.js +2 -6
- package/src/js/mixin/swipe.js +72 -0
- package/src/js/mixin/togglable.js +2 -3
- package/src/js/util/ajax.js +15 -14
- package/src/js/util/animation.js +7 -12
- package/src/js/util/dimensions.js +4 -4
- package/src/js/util/dom.js +22 -33
- package/src/js/util/filter.js +1 -2
- package/src/js/util/index.js +1 -0
- package/src/js/util/lang.js +7 -6
- package/src/js/util/observer.js +36 -0
- package/src/js/util/options.js +2 -11
- package/src/js/util/player.js +5 -4
- package/src/js/util/selector.js +12 -18
- package/src/js/util/style.js +4 -4
- package/src/less/components/base.less +10 -33
- package/src/less/components/form-range.less +48 -95
- package/src/less/components/form.less +0 -1
- package/src/less/components/height.less +3 -0
- package/src/less/components/leader.less +0 -1
- package/src/less/components/lightbox.less +0 -1
- package/src/less/components/modal.less +3 -7
- package/src/less/components/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 +6 -3
- package/src/scss/components/base.scss +10 -33
- package/src/scss/components/form-range.scss +48 -95
- package/src/scss/components/form.scss +0 -1
- package/src/scss/components/height.scss +3 -0
- 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/progress.scss +14 -36
- 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 +6 -3
- package/src/scss/mixins-theme.scss +1 -1
- package/src/scss/mixins.scss +1 -1
- package/src/scss/variables-theme.scss +3 -3
- package/src/scss/variables.scss +3 -3
- 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/countdown.html +10 -8
- package/tests/dotnav.html +3 -3
- package/tests/image.html +296 -64
- 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/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 +16 -7
- 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 +56 -71
- 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 +50 -33
- package/tests/video.html +1 -1
- package/tests/width.html +1 -1
- package/src/js/util/promise.js +0 -0
- package/tests/images/animated.gif +0 -0
package/src/js/core/switcher.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import Lazyload from '../mixin/lazyload';
|
|
2
|
+
import Swipe from '../mixin/swipe';
|
|
1
3
|
import Togglable from '../mixin/togglable';
|
|
2
4
|
import {
|
|
3
5
|
$$,
|
|
@@ -17,7 +19,7 @@ import {
|
|
|
17
19
|
} from 'uikit-util';
|
|
18
20
|
|
|
19
21
|
export default {
|
|
20
|
-
mixins: [Togglable],
|
|
22
|
+
mixins: [Lazyload, Swipe, Togglable],
|
|
21
23
|
|
|
22
24
|
args: 'connect',
|
|
23
25
|
|
|
@@ -26,7 +28,6 @@ export default {
|
|
|
26
28
|
toggle: String,
|
|
27
29
|
itemNav: String,
|
|
28
30
|
active: Number,
|
|
29
|
-
swiping: Boolean,
|
|
30
31
|
},
|
|
31
32
|
|
|
32
33
|
data: {
|
|
@@ -34,7 +35,6 @@ export default {
|
|
|
34
35
|
toggle: '> * > :first-child',
|
|
35
36
|
itemNav: false,
|
|
36
37
|
active: 0,
|
|
37
|
-
swiping: true,
|
|
38
38
|
cls: 'uk-active',
|
|
39
39
|
attrItem: 'uk-switcher-item',
|
|
40
40
|
},
|
|
@@ -79,6 +79,14 @@ export default {
|
|
|
79
79
|
this.toggles.some((toggle) => within(toggle, child))
|
|
80
80
|
);
|
|
81
81
|
},
|
|
82
|
+
|
|
83
|
+
swipeTarget() {
|
|
84
|
+
return this.connects;
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
connected() {
|
|
89
|
+
this.lazyload(this.$el, this.connects);
|
|
82
90
|
},
|
|
83
91
|
|
|
84
92
|
events: [
|
package/src/js/core/toggle.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Lazyload from '../mixin/lazyload';
|
|
1
2
|
import Media from '../mixin/media';
|
|
2
3
|
import Togglable from '../mixin/togglable';
|
|
3
4
|
import {
|
|
@@ -7,6 +8,7 @@ import {
|
|
|
7
8
|
includes,
|
|
8
9
|
isBoolean,
|
|
9
10
|
isFocusable,
|
|
11
|
+
isTag,
|
|
10
12
|
isTouch,
|
|
11
13
|
matches,
|
|
12
14
|
once,
|
|
@@ -21,7 +23,7 @@ import {
|
|
|
21
23
|
const KEY_SPACE = 32;
|
|
22
24
|
|
|
23
25
|
export default {
|
|
24
|
-
mixins: [Media, Togglable],
|
|
26
|
+
mixins: [Lazyload, Media, Togglable],
|
|
25
27
|
|
|
26
28
|
args: 'target',
|
|
27
29
|
|
|
@@ -43,6 +45,7 @@ export default {
|
|
|
43
45
|
if (!includes(this.mode, 'media') && !isFocusable(this.$el)) {
|
|
44
46
|
attr(this.$el, 'tabindex', '0');
|
|
45
47
|
}
|
|
48
|
+
this.lazyload(this.$el, this.target);
|
|
46
49
|
},
|
|
47
50
|
|
|
48
51
|
computed: {
|
|
@@ -134,7 +137,7 @@ export default {
|
|
|
134
137
|
name: 'keydown',
|
|
135
138
|
|
|
136
139
|
filter() {
|
|
137
|
-
return includes(this.mode, 'click') && this.$el
|
|
140
|
+
return includes(this.mode, 'click') && !isTag(this.$el, 'input');
|
|
138
141
|
},
|
|
139
142
|
|
|
140
143
|
handler(e) {
|
package/src/js/core/video.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
css,
|
|
3
|
+
hasAttr,
|
|
4
|
+
isInView,
|
|
5
|
+
isVideo,
|
|
6
|
+
isVisible,
|
|
7
|
+
mute,
|
|
8
|
+
observeIntersection,
|
|
9
|
+
pause,
|
|
10
|
+
play,
|
|
11
|
+
} from 'uikit-util';
|
|
2
12
|
|
|
3
13
|
export default {
|
|
4
14
|
args: 'autoplay',
|
|
@@ -27,6 +37,8 @@ export default {
|
|
|
27
37
|
if (this.automute) {
|
|
28
38
|
mute(this.$el);
|
|
29
39
|
}
|
|
40
|
+
|
|
41
|
+
this.registerObserver(observeIntersection(this.$el, () => this.$emit('scroll'), {}, false));
|
|
30
42
|
},
|
|
31
43
|
|
|
32
44
|
update: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
assign,
|
|
3
2
|
children,
|
|
4
3
|
css,
|
|
5
4
|
fastdom,
|
|
@@ -44,7 +43,7 @@ export default function (action, target, duration) {
|
|
|
44
43
|
|
|
45
44
|
// Reset to previous state
|
|
46
45
|
nodes.forEach((el, i) => propsFrom[i] && css(el, propsFrom[i]));
|
|
47
|
-
css(target,
|
|
46
|
+
css(target, { display: 'block', ...targetProps });
|
|
48
47
|
|
|
49
48
|
// Start transitions on next frame
|
|
50
49
|
requestAnimationFrame(() => {
|
|
@@ -76,16 +75,14 @@ function getProps(el, opacity) {
|
|
|
76
75
|
const zIndex = css(el, 'zIndex');
|
|
77
76
|
|
|
78
77
|
return isVisible(el)
|
|
79
|
-
?
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
getPositionWithMargin(el)
|
|
88
|
-
)
|
|
78
|
+
? {
|
|
79
|
+
display: '',
|
|
80
|
+
opacity: opacity ? css(el, 'opacity') : '0',
|
|
81
|
+
pointerEvents: 'none',
|
|
82
|
+
position: 'absolute',
|
|
83
|
+
zIndex: zIndex === 'auto' ? index(el) : zIndex,
|
|
84
|
+
...getPositionWithMargin(el),
|
|
85
|
+
}
|
|
89
86
|
: false;
|
|
90
87
|
}
|
|
91
88
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { $$, isFunction, observeIntersection, removeAttr, toNodes } from 'uikit-util';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
methods: {
|
|
5
|
+
lazyload(observeTargets = this.$el, targets = this.$el) {
|
|
6
|
+
this.registerObserver(
|
|
7
|
+
observeIntersection(observeTargets, (entries, observer) => {
|
|
8
|
+
for (const el of toNodes(isFunction(targets) ? targets() : targets)) {
|
|
9
|
+
$$('[loading="lazy"]', el).forEach((el) => removeAttr(el, 'loading'));
|
|
10
|
+
}
|
|
11
|
+
for (const el of entries
|
|
12
|
+
.filter(({ isIntersecting }) => isIntersecting)
|
|
13
|
+
.map(({ target }) => target)) {
|
|
14
|
+
observer.unobserve(el);
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
package/src/js/mixin/parallax.js
CHANGED
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
css,
|
|
5
5
|
Dimensions,
|
|
6
6
|
each,
|
|
7
|
+
findIndex,
|
|
7
8
|
isNumber,
|
|
8
9
|
isString,
|
|
9
10
|
isUndefined,
|
|
10
11
|
noop,
|
|
11
|
-
startsWith,
|
|
12
12
|
toFloat,
|
|
13
13
|
toPx,
|
|
14
14
|
trigger,
|
|
@@ -57,7 +57,7 @@ export default {
|
|
|
57
57
|
},
|
|
58
58
|
|
|
59
59
|
events: {
|
|
60
|
-
|
|
60
|
+
load() {
|
|
61
61
|
this.$emit();
|
|
62
62
|
},
|
|
63
63
|
},
|
|
@@ -68,50 +68,44 @@ export default {
|
|
|
68
68
|
},
|
|
69
69
|
|
|
70
70
|
getCss(percent) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{ transform: '', filter: '' }
|
|
77
|
-
);
|
|
71
|
+
const css = { transform: '', filter: '' };
|
|
72
|
+
for (const prop in this.props) {
|
|
73
|
+
this.props[prop](css, percent);
|
|
74
|
+
}
|
|
75
|
+
return css;
|
|
78
76
|
},
|
|
79
77
|
},
|
|
80
78
|
};
|
|
81
79
|
|
|
82
|
-
function transformFn(prop, el,
|
|
83
|
-
const unit = getUnit(
|
|
80
|
+
function transformFn(prop, el, stops) {
|
|
81
|
+
const unit = getUnit(stops) || { x: 'px', y: 'px', rotate: 'deg' }[prop] || '';
|
|
82
|
+
let transformFn;
|
|
84
83
|
|
|
85
84
|
if (prop === 'x' || prop === 'y') {
|
|
86
85
|
prop = `translate${ucfirst(prop)}`;
|
|
86
|
+
transformFn = (stop) => toFloat(toFloat(stop).toFixed(unit === 'px' ? 0 : 6));
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (steps.length === 1) {
|
|
92
|
-
steps.unshift(prop === 'scale' ? 1 : 0);
|
|
89
|
+
if (stops.length === 1) {
|
|
90
|
+
stops.unshift(prop === 'scale' ? 1 : 0);
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
let value = getValue(steps, percent);
|
|
93
|
+
stops = parseStops(stops, transformFn);
|
|
97
94
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
css.transform += ` ${prop}(${value}${unit})`;
|
|
95
|
+
return (css, percent) => {
|
|
96
|
+
css.transform += ` ${prop}(${getValue(stops, percent)}${unit})`;
|
|
103
97
|
};
|
|
104
98
|
}
|
|
105
99
|
|
|
106
|
-
function colorFn(prop, el,
|
|
107
|
-
if (
|
|
108
|
-
|
|
100
|
+
function colorFn(prop, el, stops) {
|
|
101
|
+
if (stops.length === 1) {
|
|
102
|
+
stops.unshift(getCssValue(el, prop, ''));
|
|
109
103
|
}
|
|
110
104
|
|
|
111
|
-
|
|
105
|
+
stops = parseStops(stops, (stop) => parseColor(el, stop));
|
|
112
106
|
|
|
113
107
|
return (css, percent) => {
|
|
114
|
-
const [start, end, p] =
|
|
108
|
+
const [start, end, p] = getStop(stops, percent);
|
|
115
109
|
const value = start
|
|
116
110
|
.map((value, i) => {
|
|
117
111
|
value += p * (end[i] - value);
|
|
@@ -131,85 +125,83 @@ function parseColor(el, color) {
|
|
|
131
125
|
.map(toFloat);
|
|
132
126
|
}
|
|
133
127
|
|
|
134
|
-
function filterFn(prop, el,
|
|
135
|
-
if (
|
|
136
|
-
|
|
128
|
+
function filterFn(prop, el, stops) {
|
|
129
|
+
if (stops.length === 1) {
|
|
130
|
+
stops.unshift(0);
|
|
137
131
|
}
|
|
138
132
|
|
|
139
|
-
const unit = getUnit(
|
|
133
|
+
const unit = getUnit(stops) || { blur: 'px', hue: 'deg' }[prop] || '%';
|
|
140
134
|
prop = { fopacity: 'opacity', hue: 'hue-rotate' }[prop] || prop;
|
|
141
|
-
|
|
135
|
+
stops = parseStops(stops);
|
|
142
136
|
|
|
143
137
|
return (css, percent) => {
|
|
144
|
-
const value = getValue(
|
|
138
|
+
const value = getValue(stops, percent);
|
|
145
139
|
css.filter += ` ${prop}(${value + unit})`;
|
|
146
140
|
};
|
|
147
141
|
}
|
|
148
142
|
|
|
149
|
-
function cssPropFn(prop, el,
|
|
150
|
-
if (
|
|
151
|
-
|
|
143
|
+
function cssPropFn(prop, el, stops) {
|
|
144
|
+
if (stops.length === 1) {
|
|
145
|
+
stops.unshift(getCssValue(el, prop, ''));
|
|
152
146
|
}
|
|
153
147
|
|
|
154
|
-
|
|
148
|
+
stops = parseStops(stops);
|
|
155
149
|
|
|
156
150
|
return (css, percent) => {
|
|
157
|
-
css[prop] = getValue(
|
|
151
|
+
css[prop] = getValue(stops, percent);
|
|
158
152
|
};
|
|
159
153
|
}
|
|
160
154
|
|
|
161
|
-
function strokeFn(prop, el,
|
|
162
|
-
if (
|
|
163
|
-
|
|
155
|
+
function strokeFn(prop, el, stops) {
|
|
156
|
+
if (stops.length === 1) {
|
|
157
|
+
stops.unshift(0);
|
|
164
158
|
}
|
|
165
159
|
|
|
166
|
-
const unit = getUnit(
|
|
167
|
-
|
|
160
|
+
const unit = getUnit(stops);
|
|
161
|
+
const length = getMaxPathLength(el);
|
|
162
|
+
stops = parseStops(stops.reverse(), (stop) => {
|
|
163
|
+
stop = toFloat(stop);
|
|
164
|
+
return unit === '%' ? (stop * length) / 100 : stop;
|
|
165
|
+
});
|
|
168
166
|
|
|
169
|
-
if (!
|
|
167
|
+
if (!stops.some(([value]) => value)) {
|
|
170
168
|
return noop;
|
|
171
169
|
}
|
|
172
170
|
|
|
173
|
-
const length = getMaxPathLength(el);
|
|
174
171
|
css(el, 'strokeDasharray', length);
|
|
175
172
|
|
|
176
|
-
if (unit === '%') {
|
|
177
|
-
steps = steps.map((step) => (step * length) / 100);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
steps = steps.reverse();
|
|
181
|
-
|
|
182
173
|
return (css, percent) => {
|
|
183
|
-
css.strokeDashoffset = getValue(
|
|
174
|
+
css.strokeDashoffset = getValue(stops, percent);
|
|
184
175
|
};
|
|
185
176
|
}
|
|
186
177
|
|
|
187
|
-
function backgroundFn(prop, el,
|
|
188
|
-
if (
|
|
189
|
-
|
|
178
|
+
function backgroundFn(prop, el, stops) {
|
|
179
|
+
if (stops.length === 1) {
|
|
180
|
+
stops.unshift(0);
|
|
190
181
|
}
|
|
191
182
|
|
|
192
183
|
prop = prop.substr(-1);
|
|
193
184
|
const attr = prop === 'y' ? 'height' : 'width';
|
|
194
|
-
|
|
185
|
+
stops = parseStops(stops, (stop) => toPx(stop, attr, el));
|
|
195
186
|
|
|
196
187
|
const bgPos = getCssValue(el, `background-position-${prop}`, '');
|
|
197
188
|
|
|
198
189
|
return getCssValue(el, 'backgroundSize', '') === 'cover'
|
|
199
|
-
? backgroundCoverFn(prop, el,
|
|
200
|
-
: setBackgroundPosFn(prop,
|
|
190
|
+
? backgroundCoverFn(prop, el, stops, bgPos, attr)
|
|
191
|
+
: setBackgroundPosFn(prop, stops, bgPos);
|
|
201
192
|
}
|
|
202
193
|
|
|
203
|
-
function backgroundCoverFn(prop, el,
|
|
194
|
+
function backgroundCoverFn(prop, el, stops, bgPos, attr) {
|
|
204
195
|
const dimImage = getBackgroundImageDimensions(el);
|
|
205
196
|
|
|
206
197
|
if (!dimImage.width) {
|
|
207
198
|
return noop;
|
|
208
199
|
}
|
|
209
200
|
|
|
210
|
-
const
|
|
211
|
-
const
|
|
212
|
-
const
|
|
201
|
+
const values = stops.map(([value]) => value);
|
|
202
|
+
const min = Math.min(...values);
|
|
203
|
+
const max = Math.max(...values);
|
|
204
|
+
const down = values.indexOf(min) < values.indexOf(max);
|
|
213
205
|
|
|
214
206
|
const diff = max - min;
|
|
215
207
|
let pos = (down ? -diff : 0) - (down ? min : max);
|
|
@@ -234,7 +226,7 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
|
234
226
|
|
|
235
227
|
const dim = Dimensions.cover(dimImage, dimEl);
|
|
236
228
|
|
|
237
|
-
const fn = setBackgroundPosFn(prop,
|
|
229
|
+
const fn = setBackgroundPosFn(prop, stops, `${pos}px`);
|
|
238
230
|
return (css, percent) => {
|
|
239
231
|
fn(css, percent);
|
|
240
232
|
css.backgroundSize = `${dim.width}px ${dim.height}px`;
|
|
@@ -242,9 +234,9 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
|
242
234
|
};
|
|
243
235
|
}
|
|
244
236
|
|
|
245
|
-
function setBackgroundPosFn(prop,
|
|
237
|
+
function setBackgroundPosFn(prop, stops, pos) {
|
|
246
238
|
return function (css, percent) {
|
|
247
|
-
css[`background-position-${prop}`] = `calc(${pos} + ${getValue(
|
|
239
|
+
css[`background-position-${prop}`] = `calc(${pos} + ${getValue(stops, percent)}px)`;
|
|
248
240
|
};
|
|
249
241
|
}
|
|
250
242
|
|
|
@@ -263,8 +255,9 @@ function getBackgroundImageDimensions(el) {
|
|
|
263
255
|
if (!image.naturalWidth) {
|
|
264
256
|
image.onload = () => {
|
|
265
257
|
dimensions[src] = toDimensions(image);
|
|
266
|
-
trigger(el, '
|
|
258
|
+
trigger(el, 'load');
|
|
267
259
|
};
|
|
260
|
+
return toDimensions(image);
|
|
268
261
|
}
|
|
269
262
|
}
|
|
270
263
|
|
|
@@ -278,27 +271,71 @@ function toDimensions(image) {
|
|
|
278
271
|
};
|
|
279
272
|
}
|
|
280
273
|
|
|
281
|
-
function
|
|
282
|
-
const
|
|
283
|
-
const
|
|
274
|
+
function parseStops(stops, fn = toFloat) {
|
|
275
|
+
const result = [];
|
|
276
|
+
const { length } = stops;
|
|
277
|
+
let nullIndex = 0;
|
|
278
|
+
for (let i = 0; i < length; i++) {
|
|
279
|
+
let [value, percent] = isString(stops[i]) ? stops[i].trim().split(' ') : [stops[i]];
|
|
280
|
+
value = fn(value);
|
|
281
|
+
percent = percent ? toFloat(percent) / 100 : null;
|
|
282
|
+
|
|
283
|
+
if (i === 0) {
|
|
284
|
+
if (percent === null) {
|
|
285
|
+
percent = 0;
|
|
286
|
+
} else if (percent) {
|
|
287
|
+
result.push([value, 0]);
|
|
288
|
+
}
|
|
289
|
+
} else if (i === length - 1) {
|
|
290
|
+
if (percent === null) {
|
|
291
|
+
percent = 1;
|
|
292
|
+
} else if (percent !== 1) {
|
|
293
|
+
result.push([value, percent]);
|
|
294
|
+
percent = 1;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
result.push([value, percent]);
|
|
299
|
+
|
|
300
|
+
if (percent === null) {
|
|
301
|
+
nullIndex++;
|
|
302
|
+
} else if (nullIndex) {
|
|
303
|
+
const leftPercent = result[i - nullIndex - 1][1];
|
|
304
|
+
const p = (percent - leftPercent) / (nullIndex + 1);
|
|
305
|
+
for (let j = nullIndex; j > 0; j--) {
|
|
306
|
+
result[i - j][1] = leftPercent + p * (nullIndex - j + 1);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
nullIndex = 0;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
284
315
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
316
|
+
function getStop(stops, percent) {
|
|
317
|
+
const index = findIndex(stops.slice(1), ([, targetPercent]) => percent <= targetPercent) + 1;
|
|
318
|
+
return [
|
|
319
|
+
stops[index - 1][0],
|
|
320
|
+
stops[index][0],
|
|
321
|
+
(percent - stops[index - 1][1]) / (stops[index][1] - stops[index - 1][1]),
|
|
322
|
+
];
|
|
288
323
|
}
|
|
289
324
|
|
|
290
|
-
function getValue(
|
|
291
|
-
const [start, end, p] =
|
|
325
|
+
function getValue(stops, percent) {
|
|
326
|
+
const [start, end, p] = getStop(stops, percent);
|
|
292
327
|
return isNumber(start) ? start + Math.abs(start - end) * p * (start < end ? 1 : -1) : +end;
|
|
293
328
|
}
|
|
294
329
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
330
|
+
const unitRe = /^-?\d+([^\s]*)/;
|
|
331
|
+
function getUnit(stops, defaultUnit) {
|
|
332
|
+
for (const stop of stops) {
|
|
333
|
+
const match = stop.match?.(unitRe);
|
|
334
|
+
if (match) {
|
|
335
|
+
return match[1];
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return defaultUnit;
|
|
302
339
|
}
|
|
303
340
|
|
|
304
341
|
function getCssValue(el, prop, value) {
|
package/src/js/mixin/slider.js
CHANGED
|
@@ -4,7 +4,6 @@ import SliderNav from './slider-nav';
|
|
|
4
4
|
import {
|
|
5
5
|
$,
|
|
6
6
|
$$,
|
|
7
|
-
assign,
|
|
8
7
|
clamp,
|
|
9
8
|
fastdom,
|
|
10
9
|
getIndex,
|
|
@@ -83,12 +82,6 @@ export default {
|
|
|
83
82
|
},
|
|
84
83
|
},
|
|
85
84
|
|
|
86
|
-
events: {
|
|
87
|
-
itemshown() {
|
|
88
|
-
this.$update(this.list);
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
|
|
92
85
|
methods: {
|
|
93
86
|
show(index, force = false) {
|
|
94
87
|
if (this.dragging || !this.length) {
|
|
@@ -170,21 +163,14 @@ export default {
|
|
|
170
163
|
},
|
|
171
164
|
|
|
172
165
|
_show(prev, next, force) {
|
|
173
|
-
this._transitioner = this._getTransitioner(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */
|
|
182
|
-
: 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */
|
|
183
|
-
: this.easing,
|
|
184
|
-
},
|
|
185
|
-
this.transitionOptions
|
|
186
|
-
)
|
|
187
|
-
);
|
|
166
|
+
this._transitioner = this._getTransitioner(prev, next, this.dir, {
|
|
167
|
+
easing: force
|
|
168
|
+
? next.offsetWidth < 600
|
|
169
|
+
? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */
|
|
170
|
+
: 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */
|
|
171
|
+
: this.easing,
|
|
172
|
+
...this.transitionOptions,
|
|
173
|
+
});
|
|
188
174
|
|
|
189
175
|
if (!force && !prev) {
|
|
190
176
|
this._translate(1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Animations from './internal/slideshow-animations';
|
|
2
2
|
import Transitioner from './internal/slideshow-transitioner';
|
|
3
3
|
import Slider from './slider.js';
|
|
4
|
-
import { addClass,
|
|
4
|
+
import { addClass, removeClass } from 'uikit-util';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
mixins: [Slider],
|
|
@@ -19,7 +19,7 @@ export default {
|
|
|
19
19
|
|
|
20
20
|
computed: {
|
|
21
21
|
animation({ animation, Animations }) {
|
|
22
|
-
return
|
|
22
|
+
return { ...(Animations[animation] || Animations.slide), name: animation };
|
|
23
23
|
},
|
|
24
24
|
|
|
25
25
|
transitionOptions() {
|
|
@@ -28,10 +28,6 @@ export default {
|
|
|
28
28
|
},
|
|
29
29
|
|
|
30
30
|
events: {
|
|
31
|
-
'itemshow itemhide itemshown itemhidden'({ target }) {
|
|
32
|
-
this.$update(target);
|
|
33
|
-
},
|
|
34
|
-
|
|
35
31
|
beforeitemshow({ target }) {
|
|
36
32
|
addClass(target, this.clsActive);
|
|
37
33
|
},
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getEventPos,
|
|
3
|
+
isTouch,
|
|
4
|
+
once,
|
|
5
|
+
parent,
|
|
6
|
+
pointerCancel,
|
|
7
|
+
pointerDown,
|
|
8
|
+
pointerUp,
|
|
9
|
+
trigger,
|
|
10
|
+
} from 'uikit-util';
|
|
11
|
+
import { registerEvent } from '../api/state';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
props: {
|
|
15
|
+
swiping: Boolean,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
data: {
|
|
19
|
+
swiping: true,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
computed: {
|
|
23
|
+
swipeTarget(props, $el) {
|
|
24
|
+
return $el;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
connected() {
|
|
29
|
+
if (!this.swiping) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
registerEvent(this, {
|
|
34
|
+
el: this.swipeTarget,
|
|
35
|
+
name: pointerDown,
|
|
36
|
+
passive: true,
|
|
37
|
+
handler(e) {
|
|
38
|
+
if (!isTouch(e)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Handle Swipe Gesture
|
|
43
|
+
const pos = getEventPos(e);
|
|
44
|
+
const target = 'tagName' in e.target ? e.target : parent(e.target);
|
|
45
|
+
once(document, `${pointerUp} ${pointerCancel} scroll`, (e) => {
|
|
46
|
+
const { x, y } = getEventPos(e);
|
|
47
|
+
|
|
48
|
+
// swipe
|
|
49
|
+
if (
|
|
50
|
+
(e.type !== 'scroll' && target && x && Math.abs(pos.x - x) > 100) ||
|
|
51
|
+
(y && Math.abs(pos.y - y) > 100)
|
|
52
|
+
) {
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
trigger(target, 'swipe');
|
|
55
|
+
trigger(target, `swipe${swipeDirection(pos.x, pos.y, x, y)}`);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function swipeDirection(x1, y1, x2, y2) {
|
|
65
|
+
return Math.abs(x1 - x2) >= Math.abs(y1 - y2)
|
|
66
|
+
? x1 - x2 > 0
|
|
67
|
+
? 'Left'
|
|
68
|
+
: 'Right'
|
|
69
|
+
: y1 - y2 > 0
|
|
70
|
+
? 'Up'
|
|
71
|
+
: 'Down';
|
|
72
|
+
}
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
$$,
|
|
3
3
|
addClass,
|
|
4
4
|
Animation,
|
|
5
|
-
assign,
|
|
6
5
|
css,
|
|
7
6
|
fastdom,
|
|
8
7
|
hasClass,
|
|
@@ -151,7 +150,7 @@ export default {
|
|
|
151
150
|
export function toggleHeight({ isToggled, duration, initProps, hideProps, transition, _toggle }) {
|
|
152
151
|
return (el, show) => {
|
|
153
152
|
const inProgress = Transition.inProgress(el);
|
|
154
|
-
const inner = el.hasChildNodes
|
|
153
|
+
const inner = el.hasChildNodes()
|
|
155
154
|
? toFloat(css(el.firstElementChild, 'marginTop')) +
|
|
156
155
|
toFloat(css(el.lastElementChild, 'marginBottom'))
|
|
157
156
|
: 0;
|
|
@@ -175,7 +174,7 @@ export function toggleHeight({ isToggled, duration, initProps, hideProps, transi
|
|
|
175
174
|
show
|
|
176
175
|
? Transition.start(
|
|
177
176
|
el,
|
|
178
|
-
|
|
177
|
+
{ ...initProps, overflow: 'hidden', height: endHeight },
|
|
179
178
|
Math.round(duration * (1 - currentHeight / endHeight)),
|
|
180
179
|
transition
|
|
181
180
|
)
|