uikit 3.11.2-dev.c2430c233 → 3.11.2-dev.c7ed3c19b
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 +5 -0
- package/build/.eslintrc.json +1 -3
- package/build/build.js +26 -28
- package/build/icons.js +7 -11
- package/build/less.js +48 -36
- package/build/package.json +2 -2
- package/build/prefix.js +21 -18
- package/build/publishDev.js +6 -8
- package/build/release.js +20 -17
- package/build/scope.js +21 -11
- package/build/scss.js +72 -39
- package/build/util.js +71 -62
- package/build/wrapper/icons.js +0 -2
- package/dist/css/uikit-core-rtl.css +1 -1
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +1 -1
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +1 -1
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +1 -1
- 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 +5356 -6705
- 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 +8116 -9909
- 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 +65 -82
- 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 +59 -58
- package/src/js/core/index.js +39 -39
- package/src/js/core/leader.js +9 -18
- package/src/js/core/margin.js +21 -37
- package/src/js/core/modal.js +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 +44 -49
- package/src/js/util/player.js +40 -36
- package/src/js/util/position.js +54 -46
- package/src/js/util/selector.js +34 -49
- package/src/js/util/style.js +36 -46
- package/src/js/util/viewport.js +75 -64
- package/tests/js/index.js +114 -85
- package/src/js/mixin/flex-bug.js +0 -56
- package/src/js/util/promise.js +0 -191
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import Animate from '../mixin/animate';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
$$,
|
|
4
|
+
append,
|
|
5
|
+
assign,
|
|
6
|
+
css,
|
|
7
|
+
data,
|
|
8
|
+
each,
|
|
9
|
+
fastdom,
|
|
10
|
+
children as getChildren,
|
|
11
|
+
hasClass,
|
|
12
|
+
includes,
|
|
13
|
+
isEmpty,
|
|
14
|
+
isEqual,
|
|
15
|
+
isUndefined,
|
|
16
|
+
matches,
|
|
17
|
+
parseOptions,
|
|
18
|
+
toggleClass,
|
|
19
|
+
trigger,
|
|
20
|
+
} from 'uikit-util';
|
|
3
21
|
|
|
4
22
|
export default {
|
|
5
|
-
|
|
6
23
|
mixins: [Animate],
|
|
7
24
|
|
|
8
25
|
args: 'target',
|
|
9
26
|
|
|
10
27
|
props: {
|
|
11
28
|
target: Boolean,
|
|
12
|
-
selActive: Boolean
|
|
29
|
+
selActive: Boolean,
|
|
13
30
|
},
|
|
14
31
|
|
|
15
32
|
data: {
|
|
@@ -17,35 +34,29 @@ export default {
|
|
|
17
34
|
selActive: false,
|
|
18
35
|
attrItem: 'uk-filter-control',
|
|
19
36
|
cls: 'uk-active',
|
|
20
|
-
duration: 250
|
|
37
|
+
duration: 250,
|
|
21
38
|
},
|
|
22
39
|
|
|
23
40
|
computed: {
|
|
24
|
-
|
|
25
41
|
toggles: {
|
|
26
|
-
|
|
27
|
-
get({attrItem}, $el) {
|
|
42
|
+
get({ attrItem }, $el) {
|
|
28
43
|
return $$(`[${attrItem}],[data-${attrItem}]`, $el);
|
|
29
44
|
},
|
|
30
45
|
|
|
31
46
|
watch() {
|
|
32
|
-
|
|
33
47
|
this.updateState();
|
|
34
48
|
|
|
35
49
|
if (this.selActive !== false) {
|
|
36
50
|
const actives = $$(this.selActive, this.$el);
|
|
37
|
-
this.toggles.forEach(el => toggleClass(el, this.cls, includes(actives, el)));
|
|
51
|
+
this.toggles.forEach((el) => toggleClass(el, this.cls, includes(actives, el)));
|
|
38
52
|
}
|
|
39
|
-
|
|
40
53
|
},
|
|
41
54
|
|
|
42
|
-
immediate: true
|
|
43
|
-
|
|
55
|
+
immediate: true,
|
|
44
56
|
},
|
|
45
57
|
|
|
46
58
|
children: {
|
|
47
|
-
|
|
48
|
-
get({target}, $el) {
|
|
59
|
+
get({ target }, $el) {
|
|
49
60
|
return $$(`${target} > *`, $el);
|
|
50
61
|
},
|
|
51
62
|
|
|
@@ -55,16 +66,12 @@ export default {
|
|
|
55
66
|
}
|
|
56
67
|
},
|
|
57
68
|
|
|
58
|
-
immediate: true
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
69
|
+
immediate: true,
|
|
70
|
+
},
|
|
62
71
|
},
|
|
63
72
|
|
|
64
73
|
events: [
|
|
65
|
-
|
|
66
74
|
{
|
|
67
|
-
|
|
68
75
|
name: 'click',
|
|
69
76
|
|
|
70
77
|
delegate() {
|
|
@@ -72,18 +79,13 @@ export default {
|
|
|
72
79
|
},
|
|
73
80
|
|
|
74
81
|
handler(e) {
|
|
75
|
-
|
|
76
82
|
e.preventDefault();
|
|
77
83
|
this.apply(e.current);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
84
|
+
},
|
|
85
|
+
},
|
|
83
86
|
],
|
|
84
87
|
|
|
85
88
|
methods: {
|
|
86
|
-
|
|
87
89
|
apply(el) {
|
|
88
90
|
const prevState = this.getState();
|
|
89
91
|
const newState = mergeState(el, this.attrItem, this.getState());
|
|
@@ -95,34 +97,37 @@ export default {
|
|
|
95
97
|
|
|
96
98
|
getState() {
|
|
97
99
|
return this.toggles
|
|
98
|
-
.filter(item => hasClass(item, this.cls))
|
|
99
|
-
.reduce((state, el) => mergeState(el, this.attrItem, state), {
|
|
100
|
+
.filter((item) => hasClass(item, this.cls))
|
|
101
|
+
.reduce((state, el) => mergeState(el, this.attrItem, state), {
|
|
102
|
+
filter: { '': '' },
|
|
103
|
+
sort: [],
|
|
104
|
+
});
|
|
100
105
|
},
|
|
101
106
|
|
|
102
107
|
setState(state, animate = true) {
|
|
103
|
-
|
|
104
|
-
state = assign({filter: {'': ''}, sort: []}, state);
|
|
108
|
+
state = assign({ filter: { '': '' }, sort: [] }, state);
|
|
105
109
|
|
|
106
110
|
trigger(this.$el, 'beforeFilter', [this, state]);
|
|
107
111
|
|
|
108
|
-
this.toggles.forEach(el =>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
this.toggles.forEach((el) =>
|
|
113
|
+
toggleClass(el, this.cls, !!matchFilter(el, this.attrItem, state))
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
Promise.all(
|
|
117
|
+
$$(this.target, this.$el).map((target) => {
|
|
118
|
+
const filterFn = () => {
|
|
119
|
+
applyState(state, target, getChildren(target));
|
|
120
|
+
this.$update(this.$el);
|
|
121
|
+
};
|
|
122
|
+
return animate ? this.animate(filterFn, target) : filterFn();
|
|
123
|
+
})
|
|
124
|
+
).then(() => trigger(this.$el, 'afterFilter', [this]));
|
|
118
125
|
},
|
|
119
126
|
|
|
120
127
|
updateState() {
|
|
121
128
|
fastdom.write(() => this.setState(this.getState(), false));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
129
|
+
},
|
|
130
|
+
},
|
|
126
131
|
};
|
|
127
132
|
|
|
128
133
|
function getFilter(el, attr) {
|
|
@@ -130,13 +135,13 @@ function getFilter(el, attr) {
|
|
|
130
135
|
}
|
|
131
136
|
|
|
132
137
|
function isEqualState(stateA, stateB) {
|
|
133
|
-
return ['filter', 'sort'].every(prop => isEqual(stateA[prop], stateB[prop]));
|
|
138
|
+
return ['filter', 'sort'].every((prop) => isEqual(stateA[prop], stateB[prop]));
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
function applyState(state, target, children) {
|
|
137
142
|
const selector = getSelector(state);
|
|
138
143
|
|
|
139
|
-
children.forEach(el => css(el, 'display', selector && !matches(el, selector) ? 'none' : ''));
|
|
144
|
+
children.forEach((el) => css(el, 'display', selector && !matches(el, selector) ? 'none' : ''));
|
|
140
145
|
|
|
141
146
|
const [sort, order] = state.sort;
|
|
142
147
|
|
|
@@ -149,14 +154,11 @@ function applyState(state, target, children) {
|
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
function mergeState(el, attr, state) {
|
|
152
|
-
|
|
153
157
|
const filterBy = getFilter(el, attr);
|
|
154
|
-
const {filter, group, sort, order = 'asc'} = filterBy;
|
|
158
|
+
const { filter, group, sort, order = 'asc' } = filterBy;
|
|
155
159
|
|
|
156
160
|
if (filter || isUndefined(sort)) {
|
|
157
|
-
|
|
158
161
|
if (group) {
|
|
159
|
-
|
|
160
162
|
if (filter) {
|
|
161
163
|
delete state.filter[''];
|
|
162
164
|
state.filter[group] = filter;
|
|
@@ -164,15 +166,12 @@ function mergeState(el, attr, state) {
|
|
|
164
166
|
delete state.filter[group];
|
|
165
167
|
|
|
166
168
|
if (isEmpty(state.filter) || '' in state.filter) {
|
|
167
|
-
state.filter = {'': filter || ''};
|
|
169
|
+
state.filter = { '': filter || '' };
|
|
168
170
|
}
|
|
169
|
-
|
|
170
171
|
}
|
|
171
|
-
|
|
172
172
|
} else {
|
|
173
|
-
state.filter = {'': filter || ''};
|
|
173
|
+
state.filter = { '': filter || '' };
|
|
174
174
|
}
|
|
175
|
-
|
|
176
175
|
}
|
|
177
176
|
|
|
178
177
|
if (!isUndefined(sort)) {
|
|
@@ -182,27 +181,33 @@ function mergeState(el, attr, state) {
|
|
|
182
181
|
return state;
|
|
183
182
|
}
|
|
184
183
|
|
|
185
|
-
function matchFilter(
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
function matchFilter(
|
|
185
|
+
el,
|
|
186
|
+
attr,
|
|
187
|
+
{ filter: stateFilter = { '': '' }, sort: [stateSort, stateOrder] }
|
|
188
|
+
) {
|
|
189
|
+
const { filter = '', group = '', sort, order = 'asc' } = getFilter(el, attr);
|
|
188
190
|
|
|
189
191
|
return isUndefined(sort)
|
|
190
|
-
? group in stateFilter && filter === stateFilter[group]
|
|
191
|
-
|
|
192
|
+
? (group in stateFilter && filter === stateFilter[group]) ||
|
|
193
|
+
(!filter && group && !(group in stateFilter) && !stateFilter[''])
|
|
192
194
|
: stateSort === sort && stateOrder === order;
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
function isEqualList(listA, listB) {
|
|
196
|
-
return listA.length === listB.length
|
|
197
|
-
&& listA.every(el => ~listB.indexOf(el));
|
|
198
|
+
return listA.length === listB.length && listA.every((el) => ~listB.indexOf(el));
|
|
198
199
|
}
|
|
199
200
|
|
|
200
|
-
function getSelector({filter}) {
|
|
201
|
+
function getSelector({ filter }) {
|
|
201
202
|
let selector = '';
|
|
202
|
-
each(filter, value => selector += value || '');
|
|
203
|
+
each(filter, (value) => (selector += value || ''));
|
|
203
204
|
return selector;
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
function sortItems(nodes, sort, order) {
|
|
207
|
-
return assign([], nodes).sort(
|
|
208
|
+
return assign([], nodes).sort(
|
|
209
|
+
(a, b) =>
|
|
210
|
+
data(a, sort).localeCompare(data(b, sort), undefined, { numeric: true }) *
|
|
211
|
+
(order === 'asc' || -1)
|
|
212
|
+
);
|
|
208
213
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export {default as Countdown} from './countdown';
|
|
2
|
-
export {default as Filter} from './filter';
|
|
3
|
-
export {default as Lightbox} from './lightbox';
|
|
4
|
-
export {default as LightboxPanel} from './lightbox-panel';
|
|
5
|
-
export {default as Notification} from './notification';
|
|
6
|
-
export {default as Parallax} from './parallax';
|
|
7
|
-
export {default as Slider} from './slider';
|
|
8
|
-
export {default as SliderParallax} from './slider-parallax';
|
|
9
|
-
export {default as Slideshow} from './slideshow';
|
|
10
|
-
export {default as SlideshowParallax} from './slideshow-parallax';
|
|
11
|
-
export {default as Sortable} from './sortable';
|
|
12
|
-
export {default as Tooltip} from './tooltip';
|
|
13
|
-
export {default as Upload} from './upload';
|
|
1
|
+
export { default as Countdown } from './countdown';
|
|
2
|
+
export { default as Filter } from './filter';
|
|
3
|
+
export { default as Lightbox } from './lightbox';
|
|
4
|
+
export { default as LightboxPanel } from './lightbox-panel';
|
|
5
|
+
export { default as Notification } from './notification';
|
|
6
|
+
export { default as Parallax } from './parallax';
|
|
7
|
+
export { default as Slider } from './slider';
|
|
8
|
+
export { default as SliderParallax } from './slider-parallax';
|
|
9
|
+
export { default as Slideshow } from './slideshow';
|
|
10
|
+
export { default as SlideshowParallax } from './slideshow-parallax';
|
|
11
|
+
export { default as Sortable } from './sortable';
|
|
12
|
+
export { default as Tooltip } from './tooltip';
|
|
13
|
+
export { default as Upload } from './upload';
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import Animations, {scale3d} from '../../mixin/internal/slideshow-animations';
|
|
2
|
-
import {assign, css} from 'uikit-util';
|
|
1
|
+
import Animations, { scale3d } from '../../mixin/internal/slideshow-animations';
|
|
2
|
+
import { assign, css } from 'uikit-util';
|
|
3
3
|
|
|
4
4
|
export default assign({}, Animations, {
|
|
5
|
-
|
|
6
5
|
fade: {
|
|
7
|
-
|
|
8
6
|
show() {
|
|
9
|
-
return [
|
|
10
|
-
{opacity: 0},
|
|
11
|
-
{opacity: 1}
|
|
12
|
-
];
|
|
7
|
+
return [{ opacity: 0 }, { opacity: 1 }];
|
|
13
8
|
},
|
|
14
9
|
|
|
15
10
|
percent(current) {
|
|
@@ -17,20 +12,15 @@ export default assign({}, Animations, {
|
|
|
17
12
|
},
|
|
18
13
|
|
|
19
14
|
translate(percent) {
|
|
20
|
-
return [
|
|
21
|
-
|
|
22
|
-
{opacity: percent}
|
|
23
|
-
];
|
|
24
|
-
}
|
|
25
|
-
|
|
15
|
+
return [{ opacity: 1 - percent }, { opacity: percent }];
|
|
16
|
+
},
|
|
26
17
|
},
|
|
27
18
|
|
|
28
19
|
scale: {
|
|
29
|
-
|
|
30
20
|
show() {
|
|
31
21
|
return [
|
|
32
|
-
{opacity: 0, transform: scale3d(1 - .2)},
|
|
33
|
-
{opacity: 1, transform: scale3d(1)}
|
|
22
|
+
{ opacity: 0, transform: scale3d(1 - 0.2) },
|
|
23
|
+
{ opacity: 1, transform: scale3d(1) },
|
|
34
24
|
];
|
|
35
25
|
},
|
|
36
26
|
|
|
@@ -40,11 +30,9 @@ export default assign({}, Animations, {
|
|
|
40
30
|
|
|
41
31
|
translate(percent) {
|
|
42
32
|
return [
|
|
43
|
-
{opacity: 1 - percent, transform: scale3d(1 - .2 * percent)},
|
|
44
|
-
{opacity: percent, transform: scale3d(1 - .2 + .2 * percent)}
|
|
33
|
+
{ opacity: 1 - percent, transform: scale3d(1 - 0.2 * percent) },
|
|
34
|
+
{ opacity: percent, transform: scale3d(1 - 0.2 + 0.2 * percent) },
|
|
45
35
|
];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
36
|
+
},
|
|
37
|
+
},
|
|
50
38
|
});
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import {translate} from '../../mixin/internal/slideshow-animations';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { translate } from '../../mixin/internal/slideshow-animations';
|
|
2
|
+
import {
|
|
3
|
+
children,
|
|
4
|
+
clamp,
|
|
5
|
+
createEvent,
|
|
6
|
+
css,
|
|
7
|
+
Deferred,
|
|
8
|
+
dimensions,
|
|
9
|
+
findIndex,
|
|
10
|
+
includes,
|
|
11
|
+
isRtl,
|
|
12
|
+
noop,
|
|
13
|
+
position,
|
|
14
|
+
Transition,
|
|
15
|
+
trigger,
|
|
16
|
+
} from 'uikit-util';
|
|
17
|
+
|
|
18
|
+
export default function (prev, next, dir, { center, easing, list }) {
|
|
6
19
|
const deferred = new Deferred();
|
|
7
20
|
|
|
8
21
|
const from = prev
|
|
@@ -13,26 +26,32 @@ export default function (prev, next, dir, {center, easing, list}) {
|
|
|
13
26
|
: from + dimensions(prev).width * dir * (isRtl ? -1 : 1);
|
|
14
27
|
|
|
15
28
|
return {
|
|
16
|
-
|
|
17
29
|
dir,
|
|
18
30
|
|
|
19
31
|
show(duration, percent = 0, linear) {
|
|
20
|
-
|
|
21
32
|
const timing = linear ? 'linear' : easing;
|
|
22
33
|
duration -= Math.round(duration * clamp(percent, -1, 1));
|
|
23
34
|
|
|
24
35
|
this.translate(percent);
|
|
25
36
|
|
|
26
37
|
percent = prev ? percent : clamp(percent, 0, 1);
|
|
27
|
-
triggerUpdate(this.getItemIn(), 'itemin', {percent, duration, timing, dir});
|
|
28
|
-
prev &&
|
|
38
|
+
triggerUpdate(this.getItemIn(), 'itemin', { percent, duration, timing, dir });
|
|
39
|
+
prev &&
|
|
40
|
+
triggerUpdate(this.getItemIn(true), 'itemout', {
|
|
41
|
+
percent: 1 - percent,
|
|
42
|
+
duration,
|
|
43
|
+
timing,
|
|
44
|
+
dir,
|
|
45
|
+
});
|
|
29
46
|
|
|
30
|
-
Transition
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
Transition.start(
|
|
48
|
+
list,
|
|
49
|
+
{ transform: translate(-to * (isRtl ? -1 : 1), 'px') },
|
|
50
|
+
duration,
|
|
51
|
+
timing
|
|
52
|
+
).then(deferred.resolve, noop);
|
|
33
53
|
|
|
34
54
|
return deferred.promise;
|
|
35
|
-
|
|
36
55
|
},
|
|
37
56
|
|
|
38
57
|
cancel() {
|
|
@@ -49,14 +68,20 @@ export default function (prev, next, dir, {center, easing, list}) {
|
|
|
49
68
|
},
|
|
50
69
|
|
|
51
70
|
translate(percent) {
|
|
52
|
-
|
|
53
71
|
const distance = this.getDistance() * dir * (isRtl ? -1 : 1);
|
|
54
72
|
|
|
55
|
-
css(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
css(
|
|
74
|
+
list,
|
|
75
|
+
'transform',
|
|
76
|
+
translate(
|
|
77
|
+
clamp(
|
|
78
|
+
-to + (distance - distance * percent),
|
|
79
|
+
-getWidth(list),
|
|
80
|
+
dimensions(list).width
|
|
81
|
+
) * (isRtl ? -1 : 1),
|
|
82
|
+
'px'
|
|
83
|
+
)
|
|
84
|
+
);
|
|
60
85
|
|
|
61
86
|
const actives = this.getActives();
|
|
62
87
|
const itemIn = this.getItemIn();
|
|
@@ -64,28 +89,28 @@ export default function (prev, next, dir, {center, easing, list}) {
|
|
|
64
89
|
|
|
65
90
|
percent = prev ? clamp(percent, -1, 1) : 0;
|
|
66
91
|
|
|
67
|
-
children(list)
|
|
92
|
+
for (const slide of children(list)) {
|
|
68
93
|
const isActive = includes(actives, slide);
|
|
69
94
|
const isIn = slide === itemIn;
|
|
70
95
|
const isOut = slide === itemOut;
|
|
71
|
-
const translateIn =
|
|
96
|
+
const translateIn =
|
|
97
|
+
isIn ||
|
|
98
|
+
(!isOut &&
|
|
99
|
+
(isActive ||
|
|
100
|
+
(dir * (isRtl ? -1 : 1) === -1) ^
|
|
101
|
+
(getElLeft(slide, list) > getElLeft(prev || next))));
|
|
72
102
|
|
|
73
103
|
triggerUpdate(slide, `itemtranslate${translateIn ? 'in' : 'out'}`, {
|
|
74
104
|
dir,
|
|
75
|
-
percent: isOut
|
|
76
|
-
? 1 - percent
|
|
77
|
-
: isIn
|
|
78
|
-
? percent
|
|
79
|
-
: isActive
|
|
80
|
-
? 1
|
|
81
|
-
: 0
|
|
105
|
+
percent: isOut ? 1 - percent : isIn ? percent : isActive ? 1 : 0,
|
|
82
106
|
});
|
|
83
|
-
}
|
|
84
|
-
|
|
107
|
+
}
|
|
85
108
|
},
|
|
86
109
|
|
|
87
110
|
percent() {
|
|
88
|
-
return Math.abs(
|
|
111
|
+
return Math.abs(
|
|
112
|
+
(css(list, 'transform').split(',')[4] * (isRtl ? -1 : 1) + from) / (to - from)
|
|
113
|
+
);
|
|
89
114
|
},
|
|
90
115
|
|
|
91
116
|
getDistance() {
|
|
@@ -93,7 +118,6 @@ export default function (prev, next, dir, {center, easing, list}) {
|
|
|
93
118
|
},
|
|
94
119
|
|
|
95
120
|
getItemIn(out = false) {
|
|
96
|
-
|
|
97
121
|
let actives = this.getActives();
|
|
98
122
|
let nextActives = inView(list, getLeft(next || prev, list, center));
|
|
99
123
|
|
|
@@ -103,26 +127,19 @@ export default function (prev, next, dir, {center, easing, list}) {
|
|
|
103
127
|
nextActives = temp;
|
|
104
128
|
}
|
|
105
129
|
|
|
106
|
-
return nextActives[findIndex(nextActives, el => !includes(actives, el))];
|
|
107
|
-
|
|
130
|
+
return nextActives[findIndex(nextActives, (el) => !includes(actives, el))];
|
|
108
131
|
},
|
|
109
132
|
|
|
110
133
|
getActives() {
|
|
111
134
|
return inView(list, getLeft(prev || next, list, center));
|
|
112
|
-
}
|
|
113
|
-
|
|
135
|
+
},
|
|
114
136
|
};
|
|
115
|
-
|
|
116
137
|
}
|
|
117
138
|
|
|
118
139
|
function getLeft(el, list, center) {
|
|
119
|
-
|
|
120
140
|
const left = getElLeft(el, list);
|
|
121
141
|
|
|
122
|
-
return center
|
|
123
|
-
? left - centerEl(el, list)
|
|
124
|
-
: Math.min(left, getMax(list));
|
|
125
|
-
|
|
142
|
+
return center ? left - centerEl(el, list) : Math.min(left, getMax(list));
|
|
126
143
|
}
|
|
127
144
|
|
|
128
145
|
export function getMax(list) {
|
|
@@ -138,16 +155,20 @@ function centerEl(el, list) {
|
|
|
138
155
|
}
|
|
139
156
|
|
|
140
157
|
export function getElLeft(el, list) {
|
|
141
|
-
return
|
|
158
|
+
return (
|
|
159
|
+
(el &&
|
|
160
|
+
(position(el).left + (isRtl ? dimensions(el).width - dimensions(list).width : 0)) *
|
|
161
|
+
(isRtl ? -1 : 1)) ||
|
|
162
|
+
0
|
|
163
|
+
);
|
|
142
164
|
}
|
|
143
165
|
|
|
144
166
|
function inView(list, listLeft) {
|
|
145
|
-
|
|
146
167
|
listLeft -= 1;
|
|
147
168
|
const listWidth = dimensions(list).width;
|
|
148
169
|
const listRight = listLeft + listWidth + 2;
|
|
149
170
|
|
|
150
|
-
return children(list).filter(slide => {
|
|
171
|
+
return children(list).filter((slide) => {
|
|
151
172
|
const slideLeft = getElLeft(slide, list);
|
|
152
173
|
const slideRight = slideLeft + Math.min(dimensions(slide).width, listWidth);
|
|
153
174
|
|