uikit 3.11.2-dev.4c11be04b → 3.11.2-dev.72dbb9a19
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 +21 -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 +42 -32
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +42 -32
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +42 -32
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +42 -32
- 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 +294 -356
- 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 +722 -852
- 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 +612 -802
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +587 -621
- 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 +5370 -6659
- 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 +8056 -9832
- 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-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 +21 -46
- 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 +126 -108
- 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 +107 -93
- 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 +29 -36
- 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 +49 -36
- package/src/js/core/nav.js +2 -4
- package/src/js/core/navbar.js +113 -85
- 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 +187 -116
- 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 +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 +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 +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 +76 -47
- 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 +3 -8
- package/src/js/util/filter.js +17 -34
- package/src/js/util/index.js +0 -1
- package/src/js/util/lang.js +81 -121
- package/src/js/util/mouse.js +19 -17
- package/src/js/util/options.js +35 -49
- package/src/js/util/player.js +40 -36
- package/src/js/util/position.js +54 -46
- package/src/js/util/selector.js +43 -58
- package/src/js/util/style.js +36 -46
- package/src/js/util/viewport.js +81 -66
- package/src/less/components/base.less +0 -5
- package/src/less/components/flex.less +0 -9
- package/src/less/components/leader.less +0 -1
- package/src/less/components/navbar.less +0 -7
- package/src/less/components/utility.less +22 -0
- package/src/scss/components/base.scss +0 -5
- 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/leader.scss +0 -1
- 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/js/index.js +114 -85
- package/tests/sticky-parallax.html +44 -41
- package/tests/sticky.html +56 -24
- package/src/js/mixin/flex-bug.js +0 -56
- package/src/js/util/promise.js +0 -191
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import Container from '../mixin/container';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
$,
|
|
4
|
+
append,
|
|
5
|
+
apply,
|
|
6
|
+
closest,
|
|
7
|
+
css,
|
|
8
|
+
parent,
|
|
9
|
+
pointerEnter,
|
|
10
|
+
pointerLeave,
|
|
11
|
+
remove,
|
|
12
|
+
startsWith,
|
|
13
|
+
toFloat,
|
|
14
|
+
Transition,
|
|
15
|
+
trigger,
|
|
16
|
+
} from 'uikit-util';
|
|
3
17
|
|
|
4
18
|
export default {
|
|
5
|
-
|
|
6
19
|
mixins: [Container],
|
|
7
20
|
|
|
8
21
|
functional: true,
|
|
@@ -17,53 +30,53 @@ export default {
|
|
|
17
30
|
pos: 'top-center',
|
|
18
31
|
clsContainer: 'uk-notification',
|
|
19
32
|
clsClose: 'uk-notification-close',
|
|
20
|
-
clsMsg: 'uk-notification-message'
|
|
33
|
+
clsMsg: 'uk-notification-message',
|
|
21
34
|
},
|
|
22
35
|
|
|
23
36
|
install,
|
|
24
37
|
|
|
25
38
|
computed: {
|
|
26
|
-
|
|
27
|
-
marginProp({pos}) {
|
|
39
|
+
marginProp({ pos }) {
|
|
28
40
|
return `margin${startsWith(pos, 'top') ? 'Top' : 'Bottom'}`;
|
|
29
41
|
},
|
|
30
42
|
|
|
31
43
|
startProps() {
|
|
32
|
-
return {opacity: 0, [this.marginProp]: -this.$el.offsetHeight};
|
|
33
|
-
}
|
|
34
|
-
|
|
44
|
+
return { opacity: 0, [this.marginProp]: -this.$el.offsetHeight };
|
|
45
|
+
},
|
|
35
46
|
},
|
|
36
47
|
|
|
37
48
|
created() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
const container =
|
|
50
|
+
$(`.${this.clsContainer}-${this.pos}`, this.container) ||
|
|
51
|
+
append(
|
|
52
|
+
this.container,
|
|
53
|
+
`<div class="${this.clsContainer} ${this.clsContainer}-${this.pos}" style="display: block"></div>`
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
this.$mount(
|
|
57
|
+
append(
|
|
58
|
+
container,
|
|
59
|
+
`<div class="${this.clsMsg}${this.status ? ` ${this.clsMsg}-${this.status}` : ''}">
|
|
44
60
|
<a href class="${this.clsClose}" data-uk-close></a>
|
|
45
61
|
<div>${this.message}</div>
|
|
46
62
|
</div>`
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
)
|
|
64
|
+
);
|
|
49
65
|
},
|
|
50
66
|
|
|
51
|
-
connected() {
|
|
52
|
-
|
|
67
|
+
async connected() {
|
|
53
68
|
const margin = toFloat(css(this.$el, this.marginProp));
|
|
54
|
-
Transition.start(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
).then(() => {
|
|
58
|
-
if (this.timeout) {
|
|
59
|
-
this.timer = setTimeout(this.close, this.timeout);
|
|
60
|
-
}
|
|
69
|
+
await Transition.start(css(this.$el, this.startProps), {
|
|
70
|
+
opacity: 1,
|
|
71
|
+
[this.marginProp]: margin,
|
|
61
72
|
});
|
|
62
73
|
|
|
74
|
+
if (this.timeout) {
|
|
75
|
+
this.timer = setTimeout(this.close, this.timeout);
|
|
76
|
+
}
|
|
63
77
|
},
|
|
64
78
|
|
|
65
79
|
events: {
|
|
66
|
-
|
|
67
80
|
click(e) {
|
|
68
81
|
if (closest(e.target, 'a[href="#"],a[href=""]')) {
|
|
69
82
|
e.preventDefault();
|
|
@@ -81,45 +94,38 @@ export default {
|
|
|
81
94
|
if (this.timeout) {
|
|
82
95
|
this.timer = setTimeout(this.close, this.timeout);
|
|
83
96
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
97
|
+
},
|
|
86
98
|
},
|
|
87
99
|
|
|
88
100
|
methods: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const removeFn = el => {
|
|
93
|
-
|
|
101
|
+
async close(immediate) {
|
|
102
|
+
const removeFn = (el) => {
|
|
94
103
|
const container = parent(el);
|
|
95
104
|
|
|
96
105
|
trigger(el, 'close', [this]);
|
|
97
106
|
remove(el);
|
|
98
107
|
|
|
99
|
-
if (
|
|
108
|
+
if (!container?.hasChildNodes()) {
|
|
100
109
|
remove(container);
|
|
101
110
|
}
|
|
102
|
-
|
|
103
111
|
};
|
|
104
112
|
|
|
105
113
|
if (this.timer) {
|
|
106
114
|
clearTimeout(this.timer);
|
|
107
115
|
}
|
|
108
116
|
|
|
109
|
-
if (immediate) {
|
|
110
|
-
|
|
111
|
-
} else {
|
|
112
|
-
Transition.start(this.$el, this.startProps).then(removeFn);
|
|
117
|
+
if (!immediate) {
|
|
118
|
+
await Transition.start(this.$el, this.startProps);
|
|
113
119
|
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
}
|
|
117
120
|
|
|
121
|
+
removeFn(this.$el);
|
|
122
|
+
},
|
|
123
|
+
},
|
|
118
124
|
};
|
|
119
125
|
|
|
120
126
|
function install(UIkit) {
|
|
121
127
|
UIkit.notification.closeAll = function (group, immediate) {
|
|
122
|
-
apply(document.body, el => {
|
|
128
|
+
apply(document.body, (el) => {
|
|
123
129
|
const notification = UIkit.getComponent(el, 'notification');
|
|
124
130
|
if (notification && (!group || group === notification.group)) {
|
|
125
131
|
notification.close(immediate);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Parallax from '../mixin/parallax';
|
|
2
|
-
import {css, parent, query, scrolledOver, toPx} from 'uikit-util';
|
|
2
|
+
import { css, parent, query, scrolledOver, toPx } from 'uikit-util';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
|
-
|
|
6
5
|
mixins: [Parallax],
|
|
7
6
|
|
|
8
7
|
props: {
|
|
@@ -10,7 +9,7 @@ export default {
|
|
|
10
9
|
viewport: Number, // Deprecated
|
|
11
10
|
easing: Number,
|
|
12
11
|
start: String,
|
|
13
|
-
end: String
|
|
12
|
+
end: String,
|
|
14
13
|
},
|
|
15
14
|
|
|
16
15
|
data: {
|
|
@@ -18,32 +17,30 @@ export default {
|
|
|
18
17
|
viewport: 1,
|
|
19
18
|
easing: 1,
|
|
20
19
|
start: 0,
|
|
21
|
-
end: 0
|
|
20
|
+
end: 0,
|
|
22
21
|
},
|
|
23
22
|
|
|
24
23
|
computed: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return getOffsetElement(target && query(target, $el) || $el);
|
|
24
|
+
target({ target }, $el) {
|
|
25
|
+
return getOffsetElement((target && query(target, $el)) || $el);
|
|
28
26
|
},
|
|
29
27
|
|
|
30
|
-
start({start}) {
|
|
31
|
-
return
|
|
28
|
+
start({ start }) {
|
|
29
|
+
return toPx(start, 'height', this.target, true);
|
|
32
30
|
},
|
|
33
31
|
|
|
34
|
-
end({end, viewport}) {
|
|
35
|
-
return
|
|
36
|
-
end || (viewport = (1 - viewport) * 100) && `${viewport}vh+${viewport}
|
|
37
|
-
|
|
32
|
+
end({ end, viewport }) {
|
|
33
|
+
return toPx(
|
|
34
|
+
end || ((viewport = (1 - viewport) * 100) && `${viewport}vh+${viewport}%`),
|
|
35
|
+
'height',
|
|
36
|
+
this.target,
|
|
37
|
+
true
|
|
38
38
|
);
|
|
39
|
-
}
|
|
40
|
-
|
|
39
|
+
},
|
|
41
40
|
},
|
|
42
41
|
|
|
43
42
|
update: {
|
|
44
|
-
|
|
45
|
-
read({percent}, types) {
|
|
46
|
-
|
|
43
|
+
read({ percent }, types) {
|
|
47
44
|
if (!types.has('scroll')) {
|
|
48
45
|
percent = false;
|
|
49
46
|
}
|
|
@@ -57,50 +54,28 @@ export default {
|
|
|
57
54
|
|
|
58
55
|
return {
|
|
59
56
|
percent,
|
|
60
|
-
style: prev === percent ? false : this.getCss(percent)
|
|
57
|
+
style: prev === percent ? false : this.getCss(percent),
|
|
61
58
|
};
|
|
62
59
|
},
|
|
63
60
|
|
|
64
|
-
write({style}) {
|
|
65
|
-
|
|
61
|
+
write({ style }) {
|
|
66
62
|
if (!this.matchMedia) {
|
|
67
63
|
this.reset();
|
|
68
64
|
return;
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
style && css(this.$el, style);
|
|
72
|
-
|
|
73
68
|
},
|
|
74
69
|
|
|
75
|
-
events: ['scroll', 'resize']
|
|
76
|
-
}
|
|
77
|
-
|
|
70
|
+
events: ['scroll', 'resize'],
|
|
71
|
+
},
|
|
78
72
|
};
|
|
79
73
|
|
|
80
|
-
const calcRe = /-?\d+(?:\.\d+)?(?:v[wh]|%|px)?/g;
|
|
81
|
-
function parseCalc(calc, el) {
|
|
82
|
-
let match;
|
|
83
|
-
let result = 0;
|
|
84
|
-
calc = calc.toString().replace(/\s/g, '');
|
|
85
|
-
calcRe.lastIndex = 0;
|
|
86
|
-
while ((match = calcRe.exec(calc)) !== null) {
|
|
87
|
-
result += toPx(match[0], 'height', el, true);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
74
|
function ease(percent, easing) {
|
|
94
|
-
return easing >= 0
|
|
95
|
-
? Math.pow(percent, easing + 1)
|
|
96
|
-
: 1 - Math.pow(1 - percent, -easing + 1);
|
|
75
|
+
return easing >= 0 ? Math.pow(percent, easing + 1) : 1 - Math.pow(1 - percent, -easing + 1);
|
|
97
76
|
}
|
|
98
77
|
|
|
99
78
|
// SVG elements do not inherit from HTMLElement
|
|
100
79
|
function getOffsetElement(el) {
|
|
101
|
-
return el
|
|
102
|
-
? 'offsetTop' in el
|
|
103
|
-
? el
|
|
104
|
-
: getOffsetElement(parent(el))
|
|
105
|
-
: document.documentElement;
|
|
80
|
+
return el ? ('offsetTop' in el ? el : getOffsetElement(parent(el))) : document.documentElement;
|
|
106
81
|
}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import Parallax from '../mixin/parallax';
|
|
2
|
-
import {css, endsWith, fastdom, noop, query, Transition} from 'uikit-util';
|
|
2
|
+
import { css, endsWith, fastdom, noop, query, Transition } from 'uikit-util';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
|
-
|
|
6
5
|
mixins: [Parallax],
|
|
7
6
|
|
|
8
7
|
data: {
|
|
9
|
-
selItem: '!li'
|
|
8
|
+
selItem: '!li',
|
|
10
9
|
},
|
|
11
10
|
|
|
12
11
|
computed: {
|
|
13
|
-
|
|
14
|
-
item({selItem}, $el) {
|
|
12
|
+
item({ selItem }, $el) {
|
|
15
13
|
return query(selItem, $el);
|
|
16
|
-
}
|
|
17
|
-
|
|
14
|
+
},
|
|
18
15
|
},
|
|
19
16
|
|
|
20
17
|
events: [
|
|
21
|
-
|
|
22
18
|
{
|
|
23
19
|
name: 'itemin itemout',
|
|
24
20
|
|
|
@@ -28,18 +24,16 @@ export default {
|
|
|
28
24
|
return this.item;
|
|
29
25
|
},
|
|
30
26
|
|
|
31
|
-
handler({type, detail: {percent, duration, timing, dir}}) {
|
|
32
|
-
|
|
27
|
+
handler({ type, detail: { percent, duration, timing, dir } }) {
|
|
33
28
|
fastdom.read(() => {
|
|
34
29
|
const propsFrom = this.getCss(getCurrentPercent(type, dir, percent));
|
|
35
|
-
const propsTo = this.getCss(isIn(type) ? .5 : dir > 0 ? 1 : 0);
|
|
30
|
+
const propsTo = this.getCss(isIn(type) ? 0.5 : dir > 0 ? 1 : 0);
|
|
36
31
|
fastdom.write(() => {
|
|
37
32
|
css(this.$el, propsFrom);
|
|
38
33
|
Transition.start(this.$el, propsTo, duration, timing).catch(noop);
|
|
39
34
|
});
|
|
40
35
|
});
|
|
41
|
-
|
|
42
|
-
}
|
|
36
|
+
},
|
|
43
37
|
},
|
|
44
38
|
|
|
45
39
|
{
|
|
@@ -53,8 +47,7 @@ export default {
|
|
|
53
47
|
|
|
54
48
|
handler() {
|
|
55
49
|
Transition.cancel(this.$el);
|
|
56
|
-
}
|
|
57
|
-
|
|
50
|
+
},
|
|
58
51
|
},
|
|
59
52
|
|
|
60
53
|
{
|
|
@@ -66,16 +59,14 @@ export default {
|
|
|
66
59
|
return this.item;
|
|
67
60
|
},
|
|
68
61
|
|
|
69
|
-
handler({type, detail: {percent, dir}}) {
|
|
62
|
+
handler({ type, detail: { percent, dir } }) {
|
|
70
63
|
fastdom.read(() => {
|
|
71
64
|
const props = this.getCss(getCurrentPercent(type, dir, percent));
|
|
72
65
|
fastdom.write(() => css(this.$el, props));
|
|
73
66
|
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
]
|
|
78
|
-
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
79
70
|
};
|
|
80
71
|
|
|
81
72
|
function isIn(type) {
|
|
@@ -83,8 +74,7 @@ function isIn(type) {
|
|
|
83
74
|
}
|
|
84
75
|
|
|
85
76
|
function getCurrentPercent(type, dir, percent) {
|
|
86
|
-
|
|
87
77
|
percent /= 2;
|
|
88
78
|
|
|
89
|
-
return isIn(type) ^ dir < 0 ? percent : 1 - percent;
|
|
79
|
+
return isIn(type) ^ (dir < 0) ? percent : 1 - percent;
|
|
90
80
|
}
|
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
import Class from '../mixin/class';
|
|
2
|
-
import Slider, {speedUp} from '../mixin/slider';
|
|
2
|
+
import Slider, { speedUp } from '../mixin/slider';
|
|
3
3
|
import SliderReactive from '../mixin/slider-reactive';
|
|
4
|
-
import Transitioner, {getMax, getWidth} from './internal/slider-transitioner';
|
|
5
|
-
import {
|
|
4
|
+
import Transitioner, { getMax, getWidth } from './internal/slider-transitioner';
|
|
5
|
+
import {
|
|
6
|
+
$,
|
|
7
|
+
addClass,
|
|
8
|
+
children,
|
|
9
|
+
css,
|
|
10
|
+
data,
|
|
11
|
+
dimensions,
|
|
12
|
+
findIndex,
|
|
13
|
+
includes,
|
|
14
|
+
isEmpty,
|
|
15
|
+
last,
|
|
16
|
+
sortBy,
|
|
17
|
+
toFloat,
|
|
18
|
+
toggleClass,
|
|
19
|
+
toNumber,
|
|
20
|
+
} from 'uikit-util';
|
|
6
21
|
|
|
7
22
|
export default {
|
|
8
|
-
|
|
9
23
|
mixins: [Class, Slider, SliderReactive],
|
|
10
24
|
|
|
11
25
|
props: {
|
|
12
26
|
center: Boolean,
|
|
13
|
-
sets: Boolean
|
|
27
|
+
sets: Boolean,
|
|
14
28
|
},
|
|
15
29
|
|
|
16
30
|
data: {
|
|
@@ -20,22 +34,24 @@ export default {
|
|
|
20
34
|
selList: '.uk-slider-items',
|
|
21
35
|
selNav: '.uk-slider-nav',
|
|
22
36
|
clsContainer: 'uk-slider-container',
|
|
23
|
-
Transitioner
|
|
37
|
+
Transitioner,
|
|
24
38
|
},
|
|
25
39
|
|
|
26
40
|
computed: {
|
|
27
|
-
|
|
28
41
|
avgWidth() {
|
|
29
42
|
return getWidth(this.list) / this.length;
|
|
30
43
|
},
|
|
31
44
|
|
|
32
|
-
finite({finite}) {
|
|
33
|
-
return
|
|
45
|
+
finite({ finite }) {
|
|
46
|
+
return (
|
|
47
|
+
finite ||
|
|
48
|
+
Math.ceil(getWidth(this.list)) <
|
|
49
|
+
Math.floor(dimensions(this.list).width + getMaxElWidth(this.list) + this.center)
|
|
50
|
+
);
|
|
34
51
|
},
|
|
35
52
|
|
|
36
53
|
maxIndex() {
|
|
37
|
-
|
|
38
|
-
if (!this.finite || this.center && !this.sets) {
|
|
54
|
+
if (!this.finite || (this.center && !this.sets)) {
|
|
39
55
|
return this.length - 1;
|
|
40
56
|
}
|
|
41
57
|
|
|
@@ -45,21 +61,18 @@ export default {
|
|
|
45
61
|
|
|
46
62
|
let lft = 0;
|
|
47
63
|
const max = getMax(this.list);
|
|
48
|
-
const index = findIndex(this.slides, el => {
|
|
49
|
-
|
|
64
|
+
const index = findIndex(this.slides, (el) => {
|
|
50
65
|
if (lft >= max) {
|
|
51
66
|
return true;
|
|
52
67
|
}
|
|
53
68
|
|
|
54
69
|
lft += dimensions(el).width;
|
|
55
|
-
|
|
56
70
|
});
|
|
57
71
|
|
|
58
72
|
return ~index ? index : this.length - 1;
|
|
59
73
|
},
|
|
60
74
|
|
|
61
|
-
sets({sets}) {
|
|
62
|
-
|
|
75
|
+
sets({ sets }) {
|
|
63
76
|
if (!sets) {
|
|
64
77
|
return;
|
|
65
78
|
}
|
|
@@ -71,47 +84,44 @@ export default {
|
|
|
71
84
|
let slideLeft = 0;
|
|
72
85
|
|
|
73
86
|
sets = sortBy(this.slides, 'offsetLeft').reduce((sets, slide, i) => {
|
|
74
|
-
|
|
75
87
|
const slideWidth = dimensions(slide).width;
|
|
76
88
|
const slideRight = slideLeft + slideWidth;
|
|
77
89
|
|
|
78
90
|
if (slideRight > left) {
|
|
79
|
-
|
|
80
91
|
if (!this.center && i > this.maxIndex) {
|
|
81
92
|
i = this.maxIndex;
|
|
82
93
|
}
|
|
83
94
|
|
|
84
95
|
if (!includes(sets, i)) {
|
|
85
|
-
|
|
86
96
|
const cmp = this.slides[i + 1];
|
|
87
|
-
if (
|
|
97
|
+
if (
|
|
98
|
+
this.center &&
|
|
99
|
+
cmp &&
|
|
100
|
+
slideWidth < leftCenter - dimensions(cmp).width / 2
|
|
101
|
+
) {
|
|
88
102
|
leftCenter -= slideWidth;
|
|
89
103
|
} else {
|
|
90
104
|
leftCenter = width;
|
|
91
105
|
sets.push(i);
|
|
92
106
|
left = slideLeft + width + (this.center ? slideWidth / 2 : 0);
|
|
93
107
|
}
|
|
94
|
-
|
|
95
108
|
}
|
|
96
109
|
}
|
|
97
110
|
|
|
98
111
|
slideLeft += slideWidth;
|
|
99
112
|
|
|
100
113
|
return sets;
|
|
101
|
-
|
|
102
114
|
}, []);
|
|
103
115
|
|
|
104
116
|
return !isEmpty(sets) && sets;
|
|
105
|
-
|
|
106
117
|
},
|
|
107
118
|
|
|
108
119
|
transitionOptions() {
|
|
109
120
|
return {
|
|
110
121
|
center: this.center,
|
|
111
|
-
list: this.list
|
|
122
|
+
list: this.list,
|
|
112
123
|
};
|
|
113
|
-
}
|
|
114
|
-
|
|
124
|
+
},
|
|
115
125
|
},
|
|
116
126
|
|
|
117
127
|
connected() {
|
|
@@ -119,14 +129,16 @@ export default {
|
|
|
119
129
|
},
|
|
120
130
|
|
|
121
131
|
update: {
|
|
122
|
-
|
|
123
132
|
write() {
|
|
124
|
-
this.navItems
|
|
133
|
+
for (const el of this.navItems) {
|
|
125
134
|
const index = toNumber(data(el, this.attrItem));
|
|
126
135
|
if (index !== false) {
|
|
127
|
-
el.hidden =
|
|
136
|
+
el.hidden =
|
|
137
|
+
!this.maxIndex ||
|
|
138
|
+
index > this.maxIndex ||
|
|
139
|
+
(this.sets && !includes(this.sets, index));
|
|
128
140
|
}
|
|
129
|
-
}
|
|
141
|
+
}
|
|
130
142
|
|
|
131
143
|
if (this.length && !this.dragging && !this.stack.length) {
|
|
132
144
|
this.reorder();
|
|
@@ -134,33 +146,40 @@ export default {
|
|
|
134
146
|
}
|
|
135
147
|
|
|
136
148
|
const actives = this._getTransitioner(this.index).getActives();
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
149
|
+
const activeClasses = [
|
|
150
|
+
this.clsActive,
|
|
151
|
+
((!this.sets || includes(this.sets, toFloat(this.index))) && this.clsActivated) ||
|
|
152
|
+
'',
|
|
153
|
+
];
|
|
154
|
+
for (const slide of this.slides) {
|
|
155
|
+
toggleClass(slide, activeClasses, includes(actives, slide));
|
|
141
156
|
}
|
|
142
157
|
},
|
|
143
158
|
|
|
144
|
-
events: ['resize']
|
|
145
|
-
|
|
159
|
+
events: ['resize'],
|
|
146
160
|
},
|
|
147
161
|
|
|
148
162
|
events: {
|
|
149
|
-
|
|
150
163
|
beforeitemshow(e) {
|
|
151
|
-
|
|
152
|
-
|
|
164
|
+
if (
|
|
165
|
+
!this.dragging &&
|
|
166
|
+
this.sets &&
|
|
167
|
+
this.stack.length < 2 &&
|
|
168
|
+
!includes(this.sets, this.index)
|
|
169
|
+
) {
|
|
153
170
|
this.index = this.getValidIndex();
|
|
154
171
|
}
|
|
155
172
|
|
|
156
173
|
const diff = Math.abs(
|
|
157
|
-
this.index
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
this.index -
|
|
175
|
+
this.prevIndex +
|
|
176
|
+
((this.dir > 0 && this.index < this.prevIndex) ||
|
|
177
|
+
(this.dir < 0 && this.index > this.prevIndex)
|
|
178
|
+
? (this.maxIndex + 1) * this.dir
|
|
179
|
+
: 0)
|
|
160
180
|
);
|
|
161
181
|
|
|
162
182
|
if (!this.dragging && diff > 1) {
|
|
163
|
-
|
|
164
183
|
for (let i = 0; i < diff; i++) {
|
|
165
184
|
this.stack.splice(1, 0, this.dir > 0 ? 'next' : 'previous');
|
|
166
185
|
}
|
|
@@ -169,25 +188,24 @@ export default {
|
|
|
169
188
|
return;
|
|
170
189
|
}
|
|
171
190
|
|
|
172
|
-
const index =
|
|
173
|
-
|
|
191
|
+
const index =
|
|
192
|
+
this.dir < 0 || !this.slides[this.prevIndex] ? this.index : this.prevIndex;
|
|
193
|
+
this.duration =
|
|
194
|
+
speedUp(this.avgWidth / this.velocity) *
|
|
195
|
+
(dimensions(this.slides[index]).width / this.avgWidth);
|
|
174
196
|
|
|
175
197
|
this.reorder();
|
|
176
|
-
|
|
177
198
|
},
|
|
178
199
|
|
|
179
200
|
itemshow() {
|
|
180
201
|
if (~this.prevIndex) {
|
|
181
202
|
addClass(this._getTransitioner().getItemIn(), this.clsActive);
|
|
182
203
|
}
|
|
183
|
-
}
|
|
184
|
-
|
|
204
|
+
},
|
|
185
205
|
},
|
|
186
206
|
|
|
187
207
|
methods: {
|
|
188
|
-
|
|
189
208
|
reorder() {
|
|
190
|
-
|
|
191
209
|
if (this.finite) {
|
|
192
210
|
css(this.slides, 'order', '');
|
|
193
211
|
return;
|
|
@@ -196,11 +214,10 @@ export default {
|
|
|
196
214
|
const index = this.dir > 0 && this.slides[this.prevIndex] ? this.prevIndex : this.index;
|
|
197
215
|
|
|
198
216
|
this.slides.forEach((slide, i) =>
|
|
199
|
-
css(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
: ''
|
|
217
|
+
css(
|
|
218
|
+
slide,
|
|
219
|
+
'order',
|
|
220
|
+
this.dir > 0 && i < index ? 1 : this.dir < 0 && i >= this.index ? -1 : ''
|
|
204
221
|
)
|
|
205
222
|
);
|
|
206
223
|
|
|
@@ -219,11 +236,9 @@ export default {
|
|
|
219
236
|
css(slide, 'order', slideIndex > index ? -2 : -1);
|
|
220
237
|
width -= dimensions(slide).width;
|
|
221
238
|
}
|
|
222
|
-
|
|
223
239
|
},
|
|
224
240
|
|
|
225
241
|
getValidIndex(index = this.index, prevIndex = this.prevIndex) {
|
|
226
|
-
|
|
227
242
|
index = this.getIndex(index, prevIndex);
|
|
228
243
|
|
|
229
244
|
if (!this.sets) {
|
|
@@ -233,23 +248,19 @@ export default {
|
|
|
233
248
|
let prev;
|
|
234
249
|
|
|
235
250
|
do {
|
|
236
|
-
|
|
237
251
|
if (includes(this.sets, index)) {
|
|
238
252
|
return index;
|
|
239
253
|
}
|
|
240
254
|
|
|
241
255
|
prev = index;
|
|
242
256
|
index = this.getIndex(index + this.dir, prevIndex);
|
|
243
|
-
|
|
244
257
|
} while (index !== prev);
|
|
245
258
|
|
|
246
259
|
return index;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
260
|
+
},
|
|
261
|
+
},
|
|
251
262
|
};
|
|
252
263
|
|
|
253
264
|
function getMaxElWidth(list) {
|
|
254
|
-
return Math.max(0, ...children(list).map(el => dimensions(el).width));
|
|
265
|
+
return Math.max(0, ...children(list).map((el) => dimensions(el).width));
|
|
255
266
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {default} from './slider-parallax';
|
|
1
|
+
export { default } from './slider-parallax';
|