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
|
@@ -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) {
|
|
@@ -1,49 +1,45 @@
|
|
|
1
|
-
import {$, $$, data, html, toggleClass, toNumber} from 'uikit-util';
|
|
1
|
+
import { $, $$, data, html, toggleClass, toNumber } from 'uikit-util';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
|
|
5
4
|
data: {
|
|
6
|
-
selNav: false
|
|
5
|
+
selNav: false,
|
|
7
6
|
},
|
|
8
7
|
|
|
9
8
|
computed: {
|
|
10
|
-
|
|
11
|
-
nav({selNav}, $el) {
|
|
9
|
+
nav({ selNav }, $el) {
|
|
12
10
|
return $(selNav, $el);
|
|
13
11
|
},
|
|
14
12
|
|
|
15
|
-
selNavItem({attrItem}) {
|
|
13
|
+
selNavItem({ attrItem }) {
|
|
16
14
|
return `[${attrItem}],[data-${attrItem}]`;
|
|
17
15
|
},
|
|
18
16
|
|
|
19
17
|
navItems(_, $el) {
|
|
20
18
|
return $$(this.selNavItem, $el);
|
|
21
|
-
}
|
|
22
|
-
|
|
19
|
+
},
|
|
23
20
|
},
|
|
24
21
|
|
|
25
22
|
update: {
|
|
26
|
-
|
|
27
23
|
write() {
|
|
28
|
-
|
|
29
24
|
if (this.nav && this.length !== this.nav.children.length) {
|
|
30
|
-
html(
|
|
25
|
+
html(
|
|
26
|
+
this.nav,
|
|
27
|
+
this.slides
|
|
28
|
+
.map((_, i) => `<li ${this.attrItem}="${i}"><a href></a></li>`)
|
|
29
|
+
.join('')
|
|
30
|
+
);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
this.navItems.concat(this.nav).forEach(el => el && (el.hidden = !this.maxIndex));
|
|
33
|
+
this.navItems.concat(this.nav).forEach((el) => el && (el.hidden = !this.maxIndex));
|
|
34
34
|
|
|
35
35
|
this.updateNav();
|
|
36
|
-
|
|
37
36
|
},
|
|
38
37
|
|
|
39
|
-
events: ['resize']
|
|
40
|
-
|
|
38
|
+
events: ['resize'],
|
|
41
39
|
},
|
|
42
40
|
|
|
43
41
|
events: [
|
|
44
|
-
|
|
45
42
|
{
|
|
46
|
-
|
|
47
43
|
name: 'click',
|
|
48
44
|
|
|
49
45
|
delegate() {
|
|
@@ -53,34 +49,29 @@ export default {
|
|
|
53
49
|
handler(e) {
|
|
54
50
|
e.preventDefault();
|
|
55
51
|
this.show(data(e.current, this.attrItem));
|
|
56
|
-
}
|
|
57
|
-
|
|
52
|
+
},
|
|
58
53
|
},
|
|
59
54
|
|
|
60
55
|
{
|
|
61
|
-
|
|
62
56
|
name: 'itemshow',
|
|
63
|
-
handler: 'updateNav'
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
57
|
+
handler: 'updateNav',
|
|
58
|
+
},
|
|
67
59
|
],
|
|
68
60
|
|
|
69
61
|
methods: {
|
|
70
|
-
|
|
71
62
|
updateNav() {
|
|
72
|
-
|
|
73
63
|
const i = this.getValidIndex();
|
|
74
|
-
this.navItems
|
|
75
|
-
|
|
64
|
+
for (const el of this.navItems) {
|
|
76
65
|
const cmd = data(el, this.attrItem);
|
|
77
66
|
|
|
78
67
|
toggleClass(el, this.clsActive, toNumber(cmd) === i);
|
|
79
|
-
toggleClass(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
toggleClass(
|
|
69
|
+
el,
|
|
70
|
+
'uk-invisible',
|
|
71
|
+
this.finite &&
|
|
72
|
+
((cmd === 'previous' && i === 0) || (cmd === 'next' && i >= this.maxIndex))
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
},
|
|
86
77
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
2
|
update: {
|
|
4
|
-
|
|
5
3
|
write() {
|
|
6
|
-
|
|
7
4
|
if (this.stack.length || this.dragging) {
|
|
8
5
|
return;
|
|
9
6
|
}
|
|
@@ -13,11 +10,8 @@ export default {
|
|
|
13
10
|
if (!~this.prevIndex || this.index !== index) {
|
|
14
11
|
this.show(index);
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
},
|
|
18
14
|
|
|
19
|
-
events: ['resize']
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
15
|
+
events: ['resize'],
|
|
16
|
+
},
|
|
23
17
|
};
|
package/src/js/mixin/slider.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import SliderAutoplay from './slider-autoplay';
|
|
2
2
|
import SliderDrag from './slider-drag';
|
|
3
3
|
import SliderNav from './slider-nav';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
$,
|
|
6
|
+
$$,
|
|
7
|
+
clamp,
|
|
8
|
+
fastdom,
|
|
9
|
+
getIndex,
|
|
10
|
+
hasClass,
|
|
11
|
+
isNumber,
|
|
12
|
+
isRtl,
|
|
13
|
+
removeClass,
|
|
14
|
+
trigger,
|
|
15
|
+
} from 'uikit-util';
|
|
5
16
|
|
|
6
17
|
export default {
|
|
7
|
-
|
|
8
18
|
mixins: [SliderAutoplay, SliderDrag, SliderNav],
|
|
9
19
|
|
|
10
20
|
props: {
|
|
@@ -13,7 +23,7 @@ export default {
|
|
|
13
23
|
index: Number,
|
|
14
24
|
finite: Boolean,
|
|
15
25
|
velocity: Number,
|
|
16
|
-
selSlides: String
|
|
26
|
+
selSlides: String,
|
|
17
27
|
},
|
|
18
28
|
|
|
19
29
|
data: () => ({
|
|
@@ -27,7 +37,7 @@ export default {
|
|
|
27
37
|
clsActive: 'uk-active',
|
|
28
38
|
clsActivated: false,
|
|
29
39
|
Transitioner: false,
|
|
30
|
-
transitionOptions: {}
|
|
40
|
+
transitionOptions: {},
|
|
31
41
|
}),
|
|
32
42
|
|
|
33
43
|
connected() {
|
|
@@ -41,12 +51,11 @@ export default {
|
|
|
41
51
|
},
|
|
42
52
|
|
|
43
53
|
computed: {
|
|
44
|
-
|
|
45
|
-
duration({velocity}, $el) {
|
|
54
|
+
duration({ velocity }, $el) {
|
|
46
55
|
return speedUp($el.offsetWidth / velocity);
|
|
47
56
|
},
|
|
48
57
|
|
|
49
|
-
list({selList}, $el) {
|
|
58
|
+
list({ selList }, $el) {
|
|
50
59
|
return $(selList, $el);
|
|
51
60
|
},
|
|
52
61
|
|
|
@@ -54,45 +63,38 @@ export default {
|
|
|
54
63
|
return this.length - 1;
|
|
55
64
|
},
|
|
56
65
|
|
|
57
|
-
selSlides({selList, selSlides}) {
|
|
66
|
+
selSlides({ selList, selSlides }) {
|
|
58
67
|
return `${selList} ${selSlides || '> *'}`;
|
|
59
68
|
},
|
|
60
69
|
|
|
61
70
|
slides: {
|
|
62
|
-
|
|
63
71
|
get() {
|
|
64
72
|
return $$(this.selSlides, this.$el);
|
|
65
73
|
},
|
|
66
74
|
|
|
67
75
|
watch() {
|
|
68
76
|
this.$reset();
|
|
69
|
-
}
|
|
70
|
-
|
|
77
|
+
},
|
|
71
78
|
},
|
|
72
79
|
|
|
73
80
|
length() {
|
|
74
81
|
return this.slides.length;
|
|
75
|
-
}
|
|
76
|
-
|
|
82
|
+
},
|
|
77
83
|
},
|
|
78
84
|
|
|
79
85
|
events: {
|
|
80
|
-
|
|
81
86
|
itemshown() {
|
|
82
87
|
this.$update(this.list);
|
|
83
|
-
}
|
|
84
|
-
|
|
88
|
+
},
|
|
85
89
|
},
|
|
86
90
|
|
|
87
91
|
methods: {
|
|
88
|
-
|
|
89
92
|
show(index, force = false) {
|
|
90
|
-
|
|
91
93
|
if (this.dragging || !this.length) {
|
|
92
94
|
return;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
const {stack} = this;
|
|
97
|
+
const { stack } = this;
|
|
96
98
|
const queueIndex = force ? 0 : stack.length;
|
|
97
99
|
const reset = () => {
|
|
98
100
|
stack.splice(queueIndex, 1);
|
|
@@ -105,7 +107,6 @@ export default {
|
|
|
105
107
|
stack[force ? 'unshift' : 'push'](index);
|
|
106
108
|
|
|
107
109
|
if (!force && stack.length > 1) {
|
|
108
|
-
|
|
109
110
|
if (stack.length === 2) {
|
|
110
111
|
this._transitioner.forward(Math.min(this.duration, 200));
|
|
111
112
|
}
|
|
@@ -127,8 +128,9 @@ export default {
|
|
|
127
128
|
this.prevIndex = prevIndex;
|
|
128
129
|
this.index = nextIndex;
|
|
129
130
|
|
|
130
|
-
if (
|
|
131
|
-
|
|
131
|
+
if (
|
|
132
|
+
(prev && !trigger(prev, 'beforeitemhide', [this])) ||
|
|
133
|
+
!trigger(next, 'beforeitemshow', [this, prev])
|
|
132
134
|
) {
|
|
133
135
|
this.index = this.prevIndex;
|
|
134
136
|
reset();
|
|
@@ -136,11 +138,10 @@ export default {
|
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
const promise = this._show(prev, next, force).then(() => {
|
|
139
|
-
|
|
140
141
|
prev && trigger(prev, 'itemhidden', [this]);
|
|
141
142
|
trigger(next, 'itemshown', [this]);
|
|
142
143
|
|
|
143
|
-
return new Promise(resolve => {
|
|
144
|
+
return new Promise((resolve) => {
|
|
144
145
|
fastdom.write(() => {
|
|
145
146
|
stack.shift();
|
|
146
147
|
if (stack.length) {
|
|
@@ -151,14 +152,12 @@ export default {
|
|
|
151
152
|
resolve();
|
|
152
153
|
});
|
|
153
154
|
});
|
|
154
|
-
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
prev && trigger(prev, 'itemhide', [this]);
|
|
158
158
|
trigger(next, 'itemshow', [this]);
|
|
159
159
|
|
|
160
160
|
return promise;
|
|
161
|
-
|
|
162
161
|
},
|
|
163
162
|
|
|
164
163
|
getIndex(index = this.index, prev = this.index) {
|
|
@@ -170,28 +169,25 @@ export default {
|
|
|
170
169
|
},
|
|
171
170
|
|
|
172
171
|
_show(prev, next, force) {
|
|
173
|
-
|
|
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
|
-
}, this.transitionOptions)
|
|
185
|
-
);
|
|
172
|
+
this._transitioner = this._getTransitioner(prev, next, this.dir, {
|
|
173
|
+
easing: force
|
|
174
|
+
? next.offsetWidth < 600
|
|
175
|
+
? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */
|
|
176
|
+
: 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */
|
|
177
|
+
: this.easing,
|
|
178
|
+
...this.transitionOptions,
|
|
179
|
+
});
|
|
186
180
|
|
|
187
181
|
if (!force && !prev) {
|
|
188
182
|
this._translate(1);
|
|
189
183
|
return Promise.resolve();
|
|
190
184
|
}
|
|
191
185
|
|
|
192
|
-
const {length} = this.stack;
|
|
193
|
-
return this._transitioner[length > 1 ? 'forward' : 'show'](
|
|
194
|
-
|
|
186
|
+
const { length } = this.stack;
|
|
187
|
+
return this._transitioner[length > 1 ? 'forward' : 'show'](
|
|
188
|
+
length > 1 ? Math.min(this.duration, 75 + 75 / (length - 1)) : this.duration,
|
|
189
|
+
this.percent
|
|
190
|
+
);
|
|
195
191
|
},
|
|
196
192
|
|
|
197
193
|
_getDistance(prev, next) {
|
|
@@ -204,29 +200,26 @@ export default {
|
|
|
204
200
|
return transitioner;
|
|
205
201
|
},
|
|
206
202
|
|
|
207
|
-
_getTransitioner(
|
|
203
|
+
_getTransitioner(
|
|
204
|
+
prev = this.prevIndex,
|
|
205
|
+
next = this.index,
|
|
206
|
+
dir = this.dir || 1,
|
|
207
|
+
options = this.transitionOptions
|
|
208
|
+
) {
|
|
208
209
|
return new this.Transitioner(
|
|
209
210
|
isNumber(prev) ? this.slides[prev] : prev,
|
|
210
211
|
isNumber(next) ? this.slides[next] : next,
|
|
211
212
|
dir * (isRtl ? -1 : 1),
|
|
212
213
|
options
|
|
213
214
|
);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
215
|
+
},
|
|
216
|
+
},
|
|
218
217
|
};
|
|
219
218
|
|
|
220
219
|
function getDirection(index, prevIndex) {
|
|
221
|
-
return index === 'next'
|
|
222
|
-
? 1
|
|
223
|
-
: index === 'previous'
|
|
224
|
-
? -1
|
|
225
|
-
: index < prevIndex
|
|
226
|
-
? -1
|
|
227
|
-
: 1;
|
|
220
|
+
return index === 'next' ? 1 : index === 'previous' ? -1 : index < prevIndex ? -1 : 1;
|
|
228
221
|
}
|
|
229
222
|
|
|
230
223
|
export function speedUp(x) {
|
|
231
|
-
return .5 * x + 300; // parabola through (400,500; 600,600; 1800,1200)
|
|
224
|
+
return 0.5 * x + 300; // parabola through (400,500; 600,600; 1800,1200)
|
|
232
225
|
}
|
|
@@ -1,53 +1,47 @@
|
|
|
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
|
-
|
|
8
7
|
mixins: [Slider],
|
|
9
8
|
|
|
10
9
|
props: {
|
|
11
|
-
animation: String
|
|
10
|
+
animation: String,
|
|
12
11
|
},
|
|
13
12
|
|
|
14
13
|
data: {
|
|
15
14
|
animation: 'slide',
|
|
16
15
|
clsActivated: 'uk-transition-active',
|
|
17
16
|
Animations,
|
|
18
|
-
Transitioner
|
|
17
|
+
Transitioner,
|
|
19
18
|
},
|
|
20
19
|
|
|
21
20
|
computed: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return assign(Animations[animation] || Animations.slide, {name: animation});
|
|
21
|
+
animation({ animation, Animations }) {
|
|
22
|
+
return { ...(Animations[animation] || Animations.slide), name: animation };
|
|
25
23
|
},
|
|
26
24
|
|
|
27
25
|
transitionOptions() {
|
|
28
|
-
return {animation: this.animation};
|
|
29
|
-
}
|
|
30
|
-
|
|
26
|
+
return { animation: this.animation };
|
|
27
|
+
},
|
|
31
28
|
},
|
|
32
29
|
|
|
33
30
|
events: {
|
|
34
|
-
|
|
35
|
-
'itemshow itemhide itemshown itemhidden'({target}) {
|
|
31
|
+
'itemshow itemhide itemshown itemhidden'({ target }) {
|
|
36
32
|
this.$update(target);
|
|
37
33
|
},
|
|
38
34
|
|
|
39
|
-
beforeitemshow({target}) {
|
|
35
|
+
beforeitemshow({ target }) {
|
|
40
36
|
addClass(target, this.clsActive);
|
|
41
37
|
},
|
|
42
38
|
|
|
43
|
-
itemshown({target}) {
|
|
39
|
+
itemshown({ target }) {
|
|
44
40
|
addClass(target, this.clsActivated);
|
|
45
41
|
},
|
|
46
42
|
|
|
47
|
-
itemhidden({target}) {
|
|
43
|
+
itemhidden({ target }) {
|
|
48
44
|
removeClass(target, this.clsActive, this.clsActivated);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
45
|
+
},
|
|
46
|
+
},
|
|
53
47
|
};
|