uikit 3.13.11-dev.eb080f280 → 3.14.1-dev.dadc910c0
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 +20 -1
- package/dist/css/uikit-core-rtl.css +4 -1
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +4 -1
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +4 -1
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +4 -1
- package/dist/css/uikit.min.css +1 -1
- package/dist/js/components/countdown.js +1 -1
- package/dist/js/components/countdown.min.js +1 -1
- package/dist/js/components/filter.js +1 -1
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +19 -5
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +19 -5
- 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 +62 -60
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +62 -60
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +2 -2
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +62 -60
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +1 -1
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +1 -1
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +19 -5
- package/dist/js/components/tooltip.min.js +1 -1
- package/dist/js/components/upload.js +1 -1
- package/dist/js/components/upload.min.js +1 -1
- package/dist/js/uikit-core.js +126 -68
- 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 +188 -128
- package/dist/js/uikit.min.js +1 -1
- package/package.json +1 -1
- package/src/js/components/slider.js +1 -1
- package/src/js/core/accordion.js +21 -5
- package/src/js/core/cover.js +27 -14
- package/src/js/core/drop.js +22 -2
- package/src/js/core/height-match.js +1 -1
- package/src/js/core/margin.js +9 -2
- package/src/js/core/scrollspy-nav.js +2 -2
- package/src/js/mixin/parallax.js +61 -60
- package/src/js/mixin/togglable.js +16 -2
- package/src/js/util/lang.js +34 -38
- package/src/js/util/position.js +9 -9
- package/src/less/components/nav.less +1 -0
- package/src/less/components/utility.less +1 -0
- package/src/scss/components/nav.scss +1 -0
- package/src/scss/components/utility.scss +1 -0
- package/tests/alert.html +1 -1
- package/tests/drop.html +154 -80
- package/tests/navbar.html +1 -1
- package/tests/parallax.html +8 -8
- package/tests/sticky-parallax.html +8 -8
- package/tests/sticky.html +4 -4
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "uikit",
|
|
3
3
|
"title": "UIkit",
|
|
4
4
|
"description": "UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.14.1-dev.dadc910c0",
|
|
6
6
|
"main": "dist/js/uikit.js",
|
|
7
7
|
"style": "dist/css/uikit.css",
|
|
8
8
|
"sideEffects": [
|
|
@@ -79,7 +79,7 @@ export default {
|
|
|
79
79
|
let left = 0;
|
|
80
80
|
const sets = [];
|
|
81
81
|
const width = dimensions(this.list).width;
|
|
82
|
-
for (let i
|
|
82
|
+
for (let i = 0; i < this.slides.length; i++) {
|
|
83
83
|
const slideWidth = dimensions(this.slides[i]).width;
|
|
84
84
|
|
|
85
85
|
if (left + slideWidth > width) {
|
package/src/js/core/accordion.js
CHANGED
|
@@ -28,7 +28,6 @@ export default {
|
|
|
28
28
|
multiple: Boolean,
|
|
29
29
|
toggle: String,
|
|
30
30
|
content: String,
|
|
31
|
-
transition: String,
|
|
32
31
|
offset: Number,
|
|
33
32
|
},
|
|
34
33
|
|
|
@@ -41,19 +40,16 @@ export default {
|
|
|
41
40
|
clsOpen: 'uk-open',
|
|
42
41
|
toggle: '> .uk-accordion-title',
|
|
43
42
|
content: '> .uk-accordion-content',
|
|
44
|
-
transition: 'ease',
|
|
45
43
|
offset: 0,
|
|
46
44
|
},
|
|
47
45
|
|
|
48
46
|
computed: {
|
|
49
47
|
items: {
|
|
50
48
|
get({ targets }, $el) {
|
|
51
|
-
return $$(targets, $el)
|
|
49
|
+
return $$(targets, $el);
|
|
52
50
|
},
|
|
53
51
|
|
|
54
52
|
watch(items, prev) {
|
|
55
|
-
items.forEach((el) => hide($(this.content, el), !hasClass(el, this.clsOpen)));
|
|
56
|
-
|
|
57
53
|
if (prev || hasClass(items, this.clsOpen)) {
|
|
58
54
|
return;
|
|
59
55
|
}
|
|
@@ -73,6 +69,26 @@ export default {
|
|
|
73
69
|
toggles({ toggle }) {
|
|
74
70
|
return this.items.map((item) => $(toggle, item));
|
|
75
71
|
},
|
|
72
|
+
|
|
73
|
+
contents: {
|
|
74
|
+
get({ content }) {
|
|
75
|
+
return this.items.map((item) => $(content, item));
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
watch(items) {
|
|
79
|
+
for (const el of items) {
|
|
80
|
+
hide(
|
|
81
|
+
el,
|
|
82
|
+
!hasClass(
|
|
83
|
+
this.items.find((item) => item.contains(el)),
|
|
84
|
+
this.clsOpen
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
immediate: true,
|
|
91
|
+
},
|
|
76
92
|
},
|
|
77
93
|
|
|
78
94
|
connected() {
|
package/src/js/core/cover.js
CHANGED
|
@@ -26,25 +26,38 @@ export default {
|
|
|
26
26
|
|
|
27
27
|
update: {
|
|
28
28
|
read() {
|
|
29
|
-
const
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
width: this.width || el.naturalWidth || el.videoWidth || el.clientWidth,
|
|
35
|
-
height: this.height || el.naturalHeight || el.videoHeight || el.clientHeight,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
width: width + (width % 2 ? 1 : 0),
|
|
39
|
-
height: height + (height % 2 ? 1 : 0),
|
|
40
|
-
}
|
|
41
|
-
);
|
|
29
|
+
const { ratio, cover } = Dimensions;
|
|
30
|
+
const { $el, width, height } = this;
|
|
31
|
+
|
|
32
|
+
let dim = { width, height };
|
|
42
33
|
|
|
43
34
|
if (!dim.width || !dim.height) {
|
|
35
|
+
const intrinsic = {
|
|
36
|
+
width: $el.naturalWidth || $el.videoWidth || $el.clientWidth,
|
|
37
|
+
height: $el.naturalHeight || $el.videoHeight || $el.clientHeight,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (dim.width) {
|
|
41
|
+
dim = ratio(intrinsic, 'width', dim.width);
|
|
42
|
+
} else if (height) {
|
|
43
|
+
dim = ratio(intrinsic, 'height', dim.height);
|
|
44
|
+
} else {
|
|
45
|
+
dim = intrinsic;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const { offsetHeight: coverHeight, offsetWidth: coverWidth } =
|
|
50
|
+
getPositionedParent($el) || parent($el);
|
|
51
|
+
const coverDim = cover(dim, {
|
|
52
|
+
width: coverWidth + (coverWidth % 2 ? 1 : 0),
|
|
53
|
+
height: coverHeight + (coverHeight % 2 ? 1 : 0),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (!coverDim.width || !coverDim.height) {
|
|
44
57
|
return false;
|
|
45
58
|
}
|
|
46
59
|
|
|
47
|
-
return
|
|
60
|
+
return coverDim;
|
|
48
61
|
},
|
|
49
62
|
|
|
50
63
|
write({ height, width }) {
|
package/src/js/core/drop.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
isTouch,
|
|
14
14
|
matches,
|
|
15
15
|
MouseTracker,
|
|
16
|
+
observeResize,
|
|
16
17
|
offset,
|
|
17
18
|
offsetViewport,
|
|
18
19
|
on,
|
|
@@ -44,6 +45,7 @@ export default {
|
|
|
44
45
|
boundaryAlign: Boolean,
|
|
45
46
|
delayShow: Number,
|
|
46
47
|
delayHide: Number,
|
|
48
|
+
display: String,
|
|
47
49
|
clsDrop: String,
|
|
48
50
|
},
|
|
49
51
|
|
|
@@ -54,6 +56,7 @@ export default {
|
|
|
54
56
|
boundaryAlign: false,
|
|
55
57
|
delayShow: 0,
|
|
56
58
|
delayHide: 800,
|
|
59
|
+
display: null,
|
|
57
60
|
clsDrop: false,
|
|
58
61
|
animation: ['uk-animation-fade'],
|
|
59
62
|
cls: 'uk-open',
|
|
@@ -244,7 +247,23 @@ export default {
|
|
|
244
247
|
this.hide(false);
|
|
245
248
|
}
|
|
246
249
|
}),
|
|
247
|
-
|
|
250
|
+
|
|
251
|
+
...(this.display === 'static'
|
|
252
|
+
? []
|
|
253
|
+
: (() => {
|
|
254
|
+
const handler = () => this.$emit();
|
|
255
|
+
return [
|
|
256
|
+
on(window, 'resize', handler),
|
|
257
|
+
on(document, 'scroll', handler, true),
|
|
258
|
+
(() => {
|
|
259
|
+
const observer = observeResize(
|
|
260
|
+
scrollParents(this.$el),
|
|
261
|
+
handler
|
|
262
|
+
);
|
|
263
|
+
return () => observer.disconnect();
|
|
264
|
+
})(),
|
|
265
|
+
];
|
|
266
|
+
})()),
|
|
248
267
|
]) {
|
|
249
268
|
once(this.$el, 'hide', handler, { self: true });
|
|
250
269
|
}
|
|
@@ -364,7 +383,8 @@ export default {
|
|
|
364
383
|
const boundaryOffset = boundary ? offset(boundary) : scrollParentOffset;
|
|
365
384
|
|
|
366
385
|
css(this.$el, 'maxWidth', '');
|
|
367
|
-
const maxWidth =
|
|
386
|
+
const maxWidth =
|
|
387
|
+
scrollParentOffset.width - (this.boundaryAlign ? 0 : 2 * this.viewportPadding);
|
|
368
388
|
|
|
369
389
|
if (this.pos[1] === 'justify') {
|
|
370
390
|
const prop = this.axis === 'y' ? 'width' : 'height';
|
package/src/js/core/margin.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import Resize from '../mixin/resize';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isRtl,
|
|
4
|
+
isVisible,
|
|
5
|
+
observeMutation,
|
|
6
|
+
offsetPosition,
|
|
7
|
+
toArray,
|
|
8
|
+
toggleClass,
|
|
9
|
+
} from 'uikit-util';
|
|
3
10
|
|
|
4
11
|
export default {
|
|
5
12
|
mixins: [Resize],
|
|
@@ -15,7 +22,7 @@ export default {
|
|
|
15
22
|
},
|
|
16
23
|
|
|
17
24
|
resizeTargets() {
|
|
18
|
-
return [this.$el, this.$el.children];
|
|
25
|
+
return [this.$el, ...toArray(this.$el.children)];
|
|
19
26
|
},
|
|
20
27
|
|
|
21
28
|
connected() {
|
|
@@ -71,7 +71,7 @@ export default {
|
|
|
71
71
|
if (scrollTop === max) {
|
|
72
72
|
active = length - 1;
|
|
73
73
|
} else {
|
|
74
|
-
for (
|
|
74
|
+
for (let i = 0; i < targets.length; i++) {
|
|
75
75
|
if (offset(targets[i]).top - viewport.top - this.offset > 0) {
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
@@ -90,7 +90,7 @@ export default {
|
|
|
90
90
|
const changed = active !== false && !hasClass(this.elements[active], this.cls);
|
|
91
91
|
|
|
92
92
|
this.links.forEach((el) => el.blur());
|
|
93
|
-
for (
|
|
93
|
+
for (let i = 0; i < this.elements.length; i++) {
|
|
94
94
|
toggleClass(this.elements[i], this.cls, +i === active);
|
|
95
95
|
}
|
|
96
96
|
|
package/src/js/mixin/parallax.js
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
createEvent,
|
|
5
5
|
css,
|
|
6
6
|
Dimensions,
|
|
7
|
-
each,
|
|
8
7
|
findIndex,
|
|
9
8
|
isNumber,
|
|
10
9
|
isString,
|
|
@@ -65,7 +64,9 @@ export default {
|
|
|
65
64
|
|
|
66
65
|
methods: {
|
|
67
66
|
reset() {
|
|
68
|
-
|
|
67
|
+
for (const prop in this.getCss(0)) {
|
|
68
|
+
css(this.$el, prop, '');
|
|
69
|
+
}
|
|
69
70
|
},
|
|
70
71
|
|
|
71
72
|
getCss(percent) {
|
|
@@ -78,39 +79,39 @@ export default {
|
|
|
78
79
|
},
|
|
79
80
|
};
|
|
80
81
|
|
|
81
|
-
function transformFn(prop, el,
|
|
82
|
-
let unit = getUnit(
|
|
82
|
+
function transformFn(prop, el, steps) {
|
|
83
|
+
let unit = getUnit(steps) || { x: 'px', y: 'px', rotate: 'deg' }[prop] || '';
|
|
83
84
|
let transformFn;
|
|
84
85
|
|
|
85
86
|
if (prop === 'x' || prop === 'y') {
|
|
86
87
|
prop = `translate${ucfirst(prop)}`;
|
|
87
|
-
transformFn = (
|
|
88
|
+
transformFn = (step) => toFloat(toFloat(step).toFixed(unit === 'px' ? 0 : 6));
|
|
88
89
|
} else if (prop === 'scale') {
|
|
89
90
|
unit = '';
|
|
90
|
-
transformFn = (
|
|
91
|
-
getUnit([
|
|
91
|
+
transformFn = (step) =>
|
|
92
|
+
getUnit([step]) ? toPx(step, 'width', el, true) / el.offsetWidth : step;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
if (
|
|
95
|
-
|
|
95
|
+
if (steps.length === 1) {
|
|
96
|
+
steps.unshift(prop === 'scale' ? 1 : 0);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
steps = parseSteps(steps, transformFn);
|
|
99
100
|
|
|
100
101
|
return (css, percent) => {
|
|
101
|
-
css.transform += ` ${prop}(${getValue(
|
|
102
|
+
css.transform += ` ${prop}(${getValue(steps, percent)}${unit})`;
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
function colorFn(prop, el,
|
|
106
|
-
if (
|
|
107
|
-
|
|
106
|
+
function colorFn(prop, el, steps) {
|
|
107
|
+
if (steps.length === 1) {
|
|
108
|
+
steps.unshift(getCssValue(el, prop, ''));
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
|
|
111
|
+
steps = parseSteps(steps, (step) => parseColor(el, step));
|
|
111
112
|
|
|
112
113
|
return (css, percent) => {
|
|
113
|
-
const [start, end, p] =
|
|
114
|
+
const [start, end, p] = getStep(steps, percent);
|
|
114
115
|
const value = start
|
|
115
116
|
.map((value, i) => {
|
|
116
117
|
value += p * (end[i] - value);
|
|
@@ -130,80 +131,80 @@ function parseColor(el, color) {
|
|
|
130
131
|
.map(toFloat);
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
function filterFn(prop, el,
|
|
134
|
-
if (
|
|
135
|
-
|
|
134
|
+
function filterFn(prop, el, steps) {
|
|
135
|
+
if (steps.length === 1) {
|
|
136
|
+
steps.unshift(0);
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
const unit = getUnit(
|
|
139
|
+
const unit = getUnit(steps) || { blur: 'px', hue: 'deg' }[prop] || '%';
|
|
139
140
|
prop = { fopacity: 'opacity', hue: 'hue-rotate' }[prop] || prop;
|
|
140
|
-
|
|
141
|
+
steps = parseSteps(steps);
|
|
141
142
|
|
|
142
143
|
return (css, percent) => {
|
|
143
|
-
const value = getValue(
|
|
144
|
+
const value = getValue(steps, percent);
|
|
144
145
|
css.filter += ` ${prop}(${value + unit})`;
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
function cssPropFn(prop, el,
|
|
149
|
-
if (
|
|
150
|
-
|
|
149
|
+
function cssPropFn(prop, el, steps) {
|
|
150
|
+
if (steps.length === 1) {
|
|
151
|
+
steps.unshift(getCssValue(el, prop, ''));
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
|
|
154
|
+
steps = parseSteps(steps);
|
|
154
155
|
|
|
155
156
|
return (css, percent) => {
|
|
156
|
-
css[prop] = getValue(
|
|
157
|
+
css[prop] = getValue(steps, percent);
|
|
157
158
|
};
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
function strokeFn(prop, el,
|
|
161
|
-
if (
|
|
162
|
-
|
|
161
|
+
function strokeFn(prop, el, steps) {
|
|
162
|
+
if (steps.length === 1) {
|
|
163
|
+
steps.unshift(0);
|
|
163
164
|
}
|
|
164
165
|
|
|
165
|
-
const unit = getUnit(
|
|
166
|
+
const unit = getUnit(steps);
|
|
166
167
|
const length = getMaxPathLength(el);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return unit === '%' ? (
|
|
168
|
+
steps = parseSteps(steps.reverse(), (step) => {
|
|
169
|
+
step = toFloat(step);
|
|
170
|
+
return unit === '%' ? (step * length) / 100 : step;
|
|
170
171
|
});
|
|
171
172
|
|
|
172
|
-
if (!
|
|
173
|
+
if (!steps.some(([value]) => value)) {
|
|
173
174
|
return noop;
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
css(el, 'strokeDasharray', length);
|
|
177
178
|
|
|
178
179
|
return (css, percent) => {
|
|
179
|
-
css.strokeDashoffset = getValue(
|
|
180
|
+
css.strokeDashoffset = getValue(steps, percent);
|
|
180
181
|
};
|
|
181
182
|
}
|
|
182
183
|
|
|
183
|
-
function backgroundFn(prop, el,
|
|
184
|
-
if (
|
|
185
|
-
|
|
184
|
+
function backgroundFn(prop, el, steps) {
|
|
185
|
+
if (steps.length === 1) {
|
|
186
|
+
steps.unshift(0);
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
prop = prop.substr(-1);
|
|
189
190
|
const attr = prop === 'y' ? 'height' : 'width';
|
|
190
|
-
|
|
191
|
+
steps = parseSteps(steps, (step) => toPx(step, attr, el));
|
|
191
192
|
|
|
192
193
|
const bgPos = getCssValue(el, `background-position-${prop}`, '');
|
|
193
194
|
|
|
194
195
|
return getCssValue(el, 'backgroundSize', '') === 'cover'
|
|
195
|
-
? backgroundCoverFn(prop, el,
|
|
196
|
-
: setBackgroundPosFn(prop,
|
|
196
|
+
? backgroundCoverFn(prop, el, steps, bgPos, attr)
|
|
197
|
+
: setBackgroundPosFn(prop, steps, bgPos);
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
function backgroundCoverFn(prop, el,
|
|
200
|
+
function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
200
201
|
const dimImage = getBackgroundImageDimensions(el);
|
|
201
202
|
|
|
202
203
|
if (!dimImage.width) {
|
|
203
204
|
return noop;
|
|
204
205
|
}
|
|
205
206
|
|
|
206
|
-
const values =
|
|
207
|
+
const values = steps.map(([value]) => value);
|
|
207
208
|
const min = Math.min(...values);
|
|
208
209
|
const max = Math.max(...values);
|
|
209
210
|
const down = values.indexOf(min) < values.indexOf(max);
|
|
@@ -231,7 +232,7 @@ function backgroundCoverFn(prop, el, stops, bgPos, attr) {
|
|
|
231
232
|
|
|
232
233
|
const dim = Dimensions.cover(dimImage, dimEl);
|
|
233
234
|
|
|
234
|
-
const fn = setBackgroundPosFn(prop,
|
|
235
|
+
const fn = setBackgroundPosFn(prop, steps, `${pos}px`);
|
|
235
236
|
return (css, percent) => {
|
|
236
237
|
fn(css, percent);
|
|
237
238
|
css.backgroundSize = `${dim.width}px ${dim.height}px`;
|
|
@@ -239,9 +240,9 @@ function backgroundCoverFn(prop, el, stops, bgPos, attr) {
|
|
|
239
240
|
};
|
|
240
241
|
}
|
|
241
242
|
|
|
242
|
-
function setBackgroundPosFn(prop,
|
|
243
|
+
function setBackgroundPosFn(prop, steps, pos) {
|
|
243
244
|
return function (css, percent) {
|
|
244
|
-
css[`background-position-${prop}`] = `calc(${pos} + ${getValue(
|
|
245
|
+
css[`background-position-${prop}`] = `calc(${pos} + ${getValue(steps, percent)}px)`;
|
|
245
246
|
};
|
|
246
247
|
}
|
|
247
248
|
|
|
@@ -276,12 +277,12 @@ function toDimensions(image) {
|
|
|
276
277
|
};
|
|
277
278
|
}
|
|
278
279
|
|
|
279
|
-
function
|
|
280
|
+
function parseSteps(steps, fn = toFloat) {
|
|
280
281
|
const result = [];
|
|
281
|
-
const { length } =
|
|
282
|
+
const { length } = steps;
|
|
282
283
|
let nullIndex = 0;
|
|
283
284
|
for (let i = 0; i < length; i++) {
|
|
284
|
-
let [value, percent] = isString(
|
|
285
|
+
let [value, percent] = isString(steps[i]) ? steps[i].trim().split(' ') : [steps[i]];
|
|
285
286
|
value = fn(value);
|
|
286
287
|
percent = percent ? toFloat(percent) / 100 : null;
|
|
287
288
|
|
|
@@ -318,24 +319,24 @@ function parseStops(stops, fn = toFloat) {
|
|
|
318
319
|
return result;
|
|
319
320
|
}
|
|
320
321
|
|
|
321
|
-
function
|
|
322
|
-
const index = findIndex(
|
|
322
|
+
function getStep(steps, percent) {
|
|
323
|
+
const index = findIndex(steps.slice(1), ([, targetPercent]) => percent <= targetPercent) + 1;
|
|
323
324
|
return [
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
(percent -
|
|
325
|
+
steps[index - 1][0],
|
|
326
|
+
steps[index][0],
|
|
327
|
+
(percent - steps[index - 1][1]) / (steps[index][1] - steps[index - 1][1]),
|
|
327
328
|
];
|
|
328
329
|
}
|
|
329
330
|
|
|
330
|
-
function getValue(
|
|
331
|
-
const [start, end, p] =
|
|
331
|
+
function getValue(steps, percent) {
|
|
332
|
+
const [start, end, p] = getStep(steps, percent);
|
|
332
333
|
return isNumber(start) ? start + Math.abs(start - end) * p * (start < end ? 1 : -1) : +end;
|
|
333
334
|
}
|
|
334
335
|
|
|
335
336
|
const unitRe = /^-?\d+([^\s]*)/;
|
|
336
|
-
function getUnit(
|
|
337
|
-
for (const
|
|
338
|
-
const match =
|
|
337
|
+
function getUnit(steps, defaultUnit) {
|
|
338
|
+
for (const step of steps) {
|
|
339
|
+
const match = step.match?.(unitRe);
|
|
339
340
|
if (match) {
|
|
340
341
|
return match[1];
|
|
341
342
|
}
|
|
@@ -24,6 +24,7 @@ export default {
|
|
|
24
24
|
cls: Boolean,
|
|
25
25
|
animation: 'list',
|
|
26
26
|
duration: Number,
|
|
27
|
+
velocity: Number,
|
|
27
28
|
origin: String,
|
|
28
29
|
transition: String,
|
|
29
30
|
},
|
|
@@ -32,8 +33,9 @@ export default {
|
|
|
32
33
|
cls: false,
|
|
33
34
|
animation: [false],
|
|
34
35
|
duration: 200,
|
|
36
|
+
velocity: 0.2,
|
|
35
37
|
origin: false,
|
|
36
|
-
transition: '
|
|
38
|
+
transition: 'ease',
|
|
37
39
|
clsEnter: 'uk-togglabe-enter',
|
|
38
40
|
clsLeave: 'uk-togglabe-leave',
|
|
39
41
|
|
|
@@ -44,6 +46,7 @@ export default {
|
|
|
44
46
|
paddingBottom: '',
|
|
45
47
|
marginTop: '',
|
|
46
48
|
marginBottom: '',
|
|
49
|
+
boxShadow: '',
|
|
47
50
|
},
|
|
48
51
|
|
|
49
52
|
hideProps: {
|
|
@@ -53,6 +56,7 @@ export default {
|
|
|
53
56
|
paddingBottom: 0,
|
|
54
57
|
marginTop: 0,
|
|
55
58
|
marginBottom: 0,
|
|
59
|
+
boxShadow: 'none',
|
|
56
60
|
},
|
|
57
61
|
},
|
|
58
62
|
|
|
@@ -147,7 +151,15 @@ export default {
|
|
|
147
151
|
},
|
|
148
152
|
};
|
|
149
153
|
|
|
150
|
-
export function toggleHeight({
|
|
154
|
+
export function toggleHeight({
|
|
155
|
+
isToggled,
|
|
156
|
+
duration,
|
|
157
|
+
velocity,
|
|
158
|
+
initProps,
|
|
159
|
+
hideProps,
|
|
160
|
+
transition,
|
|
161
|
+
_toggle,
|
|
162
|
+
}) {
|
|
151
163
|
return (el, show) => {
|
|
152
164
|
const inProgress = Transition.inProgress(el);
|
|
153
165
|
const inner = el.hasChildNodes()
|
|
@@ -168,6 +180,8 @@ export function toggleHeight({ isToggled, duration, initProps, hideProps, transi
|
|
|
168
180
|
fastdom.flush();
|
|
169
181
|
|
|
170
182
|
const endHeight = height(el) + (inProgress ? 0 : inner);
|
|
183
|
+
duration = velocity * el.offsetHeight + duration;
|
|
184
|
+
|
|
171
185
|
height(el, currentHeight);
|
|
172
186
|
|
|
173
187
|
return (
|
package/src/js/util/lang.js
CHANGED
|
@@ -200,48 +200,44 @@ export function pointInRect(point, rect) {
|
|
|
200
200
|
);
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const aProp = prop === 'width' ? 'height' : 'width';
|
|
206
|
-
|
|
207
|
-
return {
|
|
208
|
-
[aProp]: dimensions[prop]
|
|
209
|
-
? Math.round((value * dimensions[aProp]) / dimensions[prop])
|
|
210
|
-
: dimensions[aProp],
|
|
211
|
-
[prop]: value,
|
|
212
|
-
};
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
contain(dimensions, maxDimensions) {
|
|
216
|
-
dimensions = { ...dimensions };
|
|
217
|
-
|
|
218
|
-
each(
|
|
219
|
-
dimensions,
|
|
220
|
-
(_, prop) =>
|
|
221
|
-
(dimensions =
|
|
222
|
-
dimensions[prop] > maxDimensions[prop]
|
|
223
|
-
? this.ratio(dimensions, prop, maxDimensions[prop])
|
|
224
|
-
: dimensions)
|
|
225
|
-
);
|
|
203
|
+
function ratio(dimensions, prop, value) {
|
|
204
|
+
const aProp = prop === 'width' ? 'height' : 'width';
|
|
226
205
|
|
|
227
|
-
|
|
228
|
-
|
|
206
|
+
return {
|
|
207
|
+
[aProp]: dimensions[prop]
|
|
208
|
+
? Math.round((value * dimensions[aProp]) / dimensions[prop])
|
|
209
|
+
: dimensions[aProp],
|
|
210
|
+
[prop]: value,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
229
213
|
|
|
230
|
-
|
|
231
|
-
|
|
214
|
+
function contain(dimensions, maxDimensions) {
|
|
215
|
+
dimensions = { ...dimensions };
|
|
232
216
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
(dimensions
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
217
|
+
for (const prop in dimensions) {
|
|
218
|
+
dimensions =
|
|
219
|
+
dimensions[prop] > maxDimensions[prop]
|
|
220
|
+
? ratio(dimensions, prop, maxDimensions[prop])
|
|
221
|
+
: dimensions;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return dimensions;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function cover(dimensions, maxDimensions) {
|
|
228
|
+
dimensions = contain(dimensions, maxDimensions);
|
|
229
|
+
|
|
230
|
+
for (const prop in dimensions) {
|
|
231
|
+
dimensions =
|
|
232
|
+
dimensions[prop] < maxDimensions[prop]
|
|
233
|
+
? ratio(dimensions, prop, maxDimensions[prop])
|
|
234
|
+
: dimensions;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return dimensions;
|
|
238
|
+
}
|
|
241
239
|
|
|
242
|
-
|
|
243
|
-
},
|
|
244
|
-
};
|
|
240
|
+
export const Dimensions = { ratio, contain, cover };
|
|
245
241
|
|
|
246
242
|
export function getIndex(i, elements, current = 0, finite = false) {
|
|
247
243
|
elements = toNodes(elements);
|