uikit 3.11.2-dev.2b60845fb → 3.11.2-dev.2f4ac8e16
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 +32 -18
- package/dist/css/uikit-core-rtl.css +80 -186
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +80 -186
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +82 -192
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +82 -192
- 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 +6 -8
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +26 -55
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +27 -57
- 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 +85 -68
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +85 -68
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +60 -12
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +85 -68
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +52 -16
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +5 -7
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +2 -2
- 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 +215 -220
- 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 +397 -355
- package/dist/js/uikit.min.js +1 -1
- package/package.json +1 -1
- package/src/js/api/component.js +2 -11
- package/src/js/api/hooks.js +1 -1
- package/src/js/api/state.js +1 -1
- package/src/js/components/filter.js +2 -3
- package/src/js/components/internal/lightbox-animations.js +4 -3
- package/src/js/components/internal/slider-preload.js +37 -0
- package/src/js/components/internal/slideshow-animations.js +4 -3
- package/src/js/components/lightbox-panel.js +34 -58
- package/src/js/components/lightbox.js +1 -2
- package/src/js/components/slider.js +21 -1
- package/src/js/components/slideshow.js +8 -1
- package/src/js/components/sortable.js +1 -1
- package/src/js/core/alert.js +1 -2
- package/src/js/core/img.js +129 -114
- package/src/js/core/modal.js +1 -2
- package/src/js/core/navbar.js +3 -3
- package/src/js/core/sticky.js +1 -1
- package/src/js/core/svg.js +10 -6
- package/src/js/core/toggle.js +2 -1
- package/src/js/mixin/internal/animate-slide.js +9 -12
- package/src/js/mixin/parallax.js +85 -68
- package/src/js/mixin/slider.js +8 -16
- package/src/js/mixin/slideshow.js +2 -2
- package/src/js/mixin/togglable.js +1 -2
- package/src/js/util/ajax.js +9 -12
- package/src/js/util/animation.js +7 -12
- package/src/js/util/dom.js +27 -30
- package/src/js/util/lang.js +7 -6
- package/src/js/util/options.js +2 -11
- package/src/js/util/player.js +5 -4
- package/src/js/util/selector.js +12 -18
- package/src/js/util/style.js +4 -4
- package/src/less/components/base.less +10 -33
- package/src/less/components/form-range.less +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/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/scss/components/base.scss +10 -33
- package/src/scss/components/form-range.scss +52 -97
- package/src/scss/components/form.scss +0 -1
- package/src/scss/components/leader.scss +0 -1
- package/src/scss/components/lightbox.scss +0 -1
- package/src/scss/components/modal.scss +3 -7
- package/src/scss/components/progress.scss +14 -36
- package/src/scss/components/slider.scss +0 -3
- package/src/scss/components/slideshow.scss +0 -3
- package/src/scss/components/text.scss +16 -32
- package/src/scss/mixins-theme.scss +1 -1
- package/src/scss/mixins.scss +1 -1
- package/src/scss/variables-theme.scss +3 -3
- package/src/scss/variables.scss +3 -3
- package/tests/align.html +10 -10
- package/tests/animation.html +2 -2
- package/tests/article.html +2 -2
- package/tests/base.html +3 -3
- package/tests/card.html +10 -10
- package/tests/column.html +3 -3
- package/tests/comment.html +9 -9
- package/tests/dotnav.html +3 -3
- package/tests/image.html +296 -64
- package/tests/images/image-type.avif +0 -0
- package/tests/images/image-type.jpeg +0 -0
- package/tests/images/image-type.webp +0 -0
- package/tests/index.html +8 -8
- package/tests/lightbox.html +10 -10
- package/tests/marker.html +2 -2
- package/tests/modal.html +8 -9
- package/tests/navbar.html +2 -2
- package/tests/overlay.html +7 -7
- package/tests/parallax.html +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/tests/images/animated.gif +0 -0
package/src/js/mixin/parallax.js
CHANGED
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
css,
|
|
5
5
|
Dimensions,
|
|
6
6
|
each,
|
|
7
|
+
findIndex,
|
|
7
8
|
isNumber,
|
|
8
9
|
isString,
|
|
9
10
|
isUndefined,
|
|
10
11
|
noop,
|
|
11
|
-
startsWith,
|
|
12
12
|
toFloat,
|
|
13
13
|
toPx,
|
|
14
14
|
trigger,
|
|
@@ -79,39 +79,35 @@ export default {
|
|
|
79
79
|
},
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
function transformFn(prop, el,
|
|
83
|
-
const unit = getUnit(
|
|
82
|
+
function transformFn(prop, el, stops) {
|
|
83
|
+
const unit = getUnit(stops) || { x: 'px', y: 'px', rotate: 'deg' }[prop] || '';
|
|
84
|
+
let transformFn;
|
|
84
85
|
|
|
85
86
|
if (prop === 'x' || prop === 'y') {
|
|
86
87
|
prop = `translate${ucfirst(prop)}`;
|
|
88
|
+
transformFn = (stop) => toFloat(toFloat(stop).toFixed(unit === 'px' ? 0 : 6));
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (steps.length === 1) {
|
|
92
|
-
steps.unshift(prop === 'scale' ? 1 : 0);
|
|
91
|
+
if (stops.length === 1) {
|
|
92
|
+
stops.unshift(prop === 'scale' ? 1 : 0);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
let value = getValue(steps, percent);
|
|
97
|
-
|
|
98
|
-
if (startsWith(prop, 'translate')) {
|
|
99
|
-
value = toFloat(value).toFixed(unit === 'px' ? 0 : 6);
|
|
100
|
-
}
|
|
95
|
+
stops = parseStops(stops, transformFn);
|
|
101
96
|
|
|
102
|
-
|
|
97
|
+
return (css, percent) => {
|
|
98
|
+
css.transform += ` ${prop}(${getValue(stops, percent)}${unit})`;
|
|
103
99
|
};
|
|
104
100
|
}
|
|
105
101
|
|
|
106
|
-
function colorFn(prop, el,
|
|
107
|
-
if (
|
|
108
|
-
|
|
102
|
+
function colorFn(prop, el, stops) {
|
|
103
|
+
if (stops.length === 1) {
|
|
104
|
+
stops.unshift(getCssValue(el, prop, ''));
|
|
109
105
|
}
|
|
110
106
|
|
|
111
|
-
|
|
107
|
+
stops = parseStops(stops, (stop) => parseColor(el, stop));
|
|
112
108
|
|
|
113
109
|
return (css, percent) => {
|
|
114
|
-
const [start, end, p] =
|
|
110
|
+
const [start, end, p] = getStop(stops, percent);
|
|
115
111
|
const value = start
|
|
116
112
|
.map((value, i) => {
|
|
117
113
|
value += p * (end[i] - value);
|
|
@@ -131,85 +127,83 @@ function parseColor(el, color) {
|
|
|
131
127
|
.map(toFloat);
|
|
132
128
|
}
|
|
133
129
|
|
|
134
|
-
function filterFn(prop, el,
|
|
135
|
-
if (
|
|
136
|
-
|
|
130
|
+
function filterFn(prop, el, stops) {
|
|
131
|
+
if (stops.length === 1) {
|
|
132
|
+
stops.unshift(0);
|
|
137
133
|
}
|
|
138
134
|
|
|
139
|
-
const unit = getUnit(
|
|
135
|
+
const unit = getUnit(stops) || { blur: 'px', hue: 'deg' }[prop] || '%';
|
|
140
136
|
prop = { fopacity: 'opacity', hue: 'hue-rotate' }[prop] || prop;
|
|
141
|
-
|
|
137
|
+
stops = parseStops(stops);
|
|
142
138
|
|
|
143
139
|
return (css, percent) => {
|
|
144
|
-
const value = getValue(
|
|
140
|
+
const value = getValue(stops, percent);
|
|
145
141
|
css.filter += ` ${prop}(${value + unit})`;
|
|
146
142
|
};
|
|
147
143
|
}
|
|
148
144
|
|
|
149
|
-
function cssPropFn(prop, el,
|
|
150
|
-
if (
|
|
151
|
-
|
|
145
|
+
function cssPropFn(prop, el, stops) {
|
|
146
|
+
if (stops.length === 1) {
|
|
147
|
+
stops.unshift(getCssValue(el, prop, ''));
|
|
152
148
|
}
|
|
153
149
|
|
|
154
|
-
|
|
150
|
+
stops = parseStops(stops);
|
|
155
151
|
|
|
156
152
|
return (css, percent) => {
|
|
157
|
-
css[prop] = getValue(
|
|
153
|
+
css[prop] = getValue(stops, percent);
|
|
158
154
|
};
|
|
159
155
|
}
|
|
160
156
|
|
|
161
|
-
function strokeFn(prop, el,
|
|
162
|
-
if (
|
|
163
|
-
|
|
157
|
+
function strokeFn(prop, el, stops) {
|
|
158
|
+
if (stops.length === 1) {
|
|
159
|
+
stops.unshift(0);
|
|
164
160
|
}
|
|
165
161
|
|
|
166
|
-
const unit = getUnit(
|
|
167
|
-
|
|
162
|
+
const unit = getUnit(stops);
|
|
163
|
+
const length = getMaxPathLength(el);
|
|
164
|
+
stops = parseStops(stops.reverse(), (stop) => {
|
|
165
|
+
stop = toFloat(stop);
|
|
166
|
+
return unit === '%' ? (stop * length) / 100 : stop;
|
|
167
|
+
});
|
|
168
168
|
|
|
169
|
-
if (!
|
|
169
|
+
if (!stops.some(([value]) => value)) {
|
|
170
170
|
return noop;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
const length = getMaxPathLength(el);
|
|
174
173
|
css(el, 'strokeDasharray', length);
|
|
175
174
|
|
|
176
|
-
if (unit === '%') {
|
|
177
|
-
steps = steps.map((step) => (step * length) / 100);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
steps = steps.reverse();
|
|
181
|
-
|
|
182
175
|
return (css, percent) => {
|
|
183
|
-
css.strokeDashoffset = getValue(
|
|
176
|
+
css.strokeDashoffset = getValue(stops, percent);
|
|
184
177
|
};
|
|
185
178
|
}
|
|
186
179
|
|
|
187
|
-
function backgroundFn(prop, el,
|
|
188
|
-
if (
|
|
189
|
-
|
|
180
|
+
function backgroundFn(prop, el, stops) {
|
|
181
|
+
if (stops.length === 1) {
|
|
182
|
+
stops.unshift(0);
|
|
190
183
|
}
|
|
191
184
|
|
|
192
185
|
prop = prop.substr(-1);
|
|
193
186
|
const attr = prop === 'y' ? 'height' : 'width';
|
|
194
|
-
|
|
187
|
+
stops = parseStops(stops, (stop) => toPx(stop, attr, el));
|
|
195
188
|
|
|
196
189
|
const bgPos = getCssValue(el, `background-position-${prop}`, '');
|
|
197
190
|
|
|
198
191
|
return getCssValue(el, 'backgroundSize', '') === 'cover'
|
|
199
|
-
? backgroundCoverFn(prop, el,
|
|
200
|
-
: setBackgroundPosFn(prop,
|
|
192
|
+
? backgroundCoverFn(prop, el, stops, bgPos, attr)
|
|
193
|
+
: setBackgroundPosFn(prop, stops, bgPos);
|
|
201
194
|
}
|
|
202
195
|
|
|
203
|
-
function backgroundCoverFn(prop, el,
|
|
196
|
+
function backgroundCoverFn(prop, el, stops, bgPos, attr) {
|
|
204
197
|
const dimImage = getBackgroundImageDimensions(el);
|
|
205
198
|
|
|
206
199
|
if (!dimImage.width) {
|
|
207
200
|
return noop;
|
|
208
201
|
}
|
|
209
202
|
|
|
210
|
-
const
|
|
211
|
-
const
|
|
212
|
-
const
|
|
203
|
+
const values = stops.map(([value]) => value);
|
|
204
|
+
const min = Math.min(...values);
|
|
205
|
+
const max = Math.max(...values);
|
|
206
|
+
const down = values.indexOf(min) < values.indexOf(max);
|
|
213
207
|
|
|
214
208
|
const diff = max - min;
|
|
215
209
|
let pos = (down ? -diff : 0) - (down ? min : max);
|
|
@@ -234,7 +228,7 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
|
234
228
|
|
|
235
229
|
const dim = Dimensions.cover(dimImage, dimEl);
|
|
236
230
|
|
|
237
|
-
const fn = setBackgroundPosFn(prop,
|
|
231
|
+
const fn = setBackgroundPosFn(prop, stops, `${pos}px`);
|
|
238
232
|
return (css, percent) => {
|
|
239
233
|
fn(css, percent);
|
|
240
234
|
css.backgroundSize = `${dim.width}px ${dim.height}px`;
|
|
@@ -242,9 +236,9 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
|
|
|
242
236
|
};
|
|
243
237
|
}
|
|
244
238
|
|
|
245
|
-
function setBackgroundPosFn(prop,
|
|
239
|
+
function setBackgroundPosFn(prop, stops, pos) {
|
|
246
240
|
return function (css, percent) {
|
|
247
|
-
css[`background-position-${prop}`] = `calc(${pos} + ${getValue(
|
|
241
|
+
css[`background-position-${prop}`] = `calc(${pos} + ${getValue(stops, percent)}px)`;
|
|
248
242
|
};
|
|
249
243
|
}
|
|
250
244
|
|
|
@@ -278,24 +272,47 @@ function toDimensions(image) {
|
|
|
278
272
|
};
|
|
279
273
|
}
|
|
280
274
|
|
|
281
|
-
function
|
|
282
|
-
const
|
|
283
|
-
const
|
|
275
|
+
function parseStops(stops, fn = toFloat) {
|
|
276
|
+
const result = [];
|
|
277
|
+
for (const stop of stops) {
|
|
278
|
+
const [value, percent] = isString(stop) ? stop.trim().split(' ') : [stop];
|
|
279
|
+
result.push([fn(value), percent ? toFloat(percent) / 100 : null]);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const { length } = result;
|
|
283
|
+
result[0][1] = 0;
|
|
284
|
+
result[length - 1][1] = 1;
|
|
285
|
+
for (let i = 1; i < length - 1; i++) {
|
|
286
|
+
if (result[i] === null) {
|
|
287
|
+
const nextIndex = findIndex(result.slice(i + 1), ([, percent]) => percent !== null) + 1;
|
|
288
|
+
const percent = (result[i + nextIndex] - result[i - 1][1]) / (nextIndex + 1);
|
|
289
|
+
for (let j = 0; j < nextIndex; j++) {
|
|
290
|
+
result[i + j][1] = percent * j + 1;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
284
297
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
298
|
+
function getStop(stops, percent) {
|
|
299
|
+
const index = findIndex(stops.slice(1), ([, targetPercent]) => percent <= targetPercent) + 1;
|
|
300
|
+
return [
|
|
301
|
+
stops[index - 1][0],
|
|
302
|
+
stops[index][0],
|
|
303
|
+
(percent - stops[index - 1][1]) / (stops[index][1] - stops[index - 1][1]),
|
|
304
|
+
];
|
|
288
305
|
}
|
|
289
306
|
|
|
290
|
-
function getValue(
|
|
291
|
-
const [start, end, p] =
|
|
307
|
+
function getValue(stops, percent) {
|
|
308
|
+
const [start, end, p] = getStop(stops, percent);
|
|
292
309
|
return isNumber(start) ? start + Math.abs(start - end) * p * (start < end ? 1 : -1) : +end;
|
|
293
310
|
}
|
|
294
311
|
|
|
295
|
-
function getUnit(
|
|
312
|
+
function getUnit(stops, defaultUnit) {
|
|
296
313
|
return (
|
|
297
|
-
|
|
298
|
-
(unit,
|
|
314
|
+
stops.reduce(
|
|
315
|
+
(unit, stop) => unit || (isString(stop) && stop.replace(/[\d-]/g, '').trim()),
|
|
299
316
|
''
|
|
300
317
|
) || defaultUnit
|
|
301
318
|
);
|
package/src/js/mixin/slider.js
CHANGED
|
@@ -4,7 +4,6 @@ import SliderNav from './slider-nav';
|
|
|
4
4
|
import {
|
|
5
5
|
$,
|
|
6
6
|
$$,
|
|
7
|
-
assign,
|
|
8
7
|
clamp,
|
|
9
8
|
fastdom,
|
|
10
9
|
getIndex,
|
|
@@ -170,21 +169,14 @@ export default {
|
|
|
170
169
|
},
|
|
171
170
|
|
|
172
171
|
_show(prev, next, force) {
|
|
173
|
-
this._transitioner = this._getTransitioner(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */
|
|
182
|
-
: 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */
|
|
183
|
-
: this.easing,
|
|
184
|
-
},
|
|
185
|
-
this.transitionOptions
|
|
186
|
-
)
|
|
187
|
-
);
|
|
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
|
+
});
|
|
188
180
|
|
|
189
181
|
if (!force && !prev) {
|
|
190
182
|
this._translate(1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Animations from './internal/slideshow-animations';
|
|
2
2
|
import Transitioner from './internal/slideshow-transitioner';
|
|
3
3
|
import Slider from './slider.js';
|
|
4
|
-
import { addClass,
|
|
4
|
+
import { addClass, removeClass } from 'uikit-util';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
mixins: [Slider],
|
|
@@ -19,7 +19,7 @@ export default {
|
|
|
19
19
|
|
|
20
20
|
computed: {
|
|
21
21
|
animation({ animation, Animations }) {
|
|
22
|
-
return
|
|
22
|
+
return { ...(Animations[animation] || Animations.slide), name: animation };
|
|
23
23
|
},
|
|
24
24
|
|
|
25
25
|
transitionOptions() {
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
$$,
|
|
3
3
|
addClass,
|
|
4
4
|
Animation,
|
|
5
|
-
assign,
|
|
6
5
|
css,
|
|
7
6
|
fastdom,
|
|
8
7
|
hasClass,
|
|
@@ -175,7 +174,7 @@ export function toggleHeight({ isToggled, duration, initProps, hideProps, transi
|
|
|
175
174
|
show
|
|
176
175
|
? Transition.start(
|
|
177
176
|
el,
|
|
178
|
-
|
|
177
|
+
{ ...initProps, overflow: 'hidden', height: endHeight },
|
|
179
178
|
Math.round(duration * (1 - currentHeight / endHeight)),
|
|
180
179
|
transition
|
|
181
180
|
)
|
package/src/js/util/ajax.js
CHANGED
|
@@ -2,18 +2,15 @@ import { on } from './event';
|
|
|
2
2
|
import { assign, noop } from './lang';
|
|
3
3
|
|
|
4
4
|
export function ajax(url, options) {
|
|
5
|
-
const env =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
options
|
|
15
|
-
);
|
|
16
|
-
|
|
5
|
+
const env = {
|
|
6
|
+
data: null,
|
|
7
|
+
method: 'GET',
|
|
8
|
+
headers: {},
|
|
9
|
+
xhr: new XMLHttpRequest(),
|
|
10
|
+
beforeSend: noop,
|
|
11
|
+
responseType: '',
|
|
12
|
+
...options,
|
|
13
|
+
};
|
|
17
14
|
return Promise.resolve()
|
|
18
15
|
.then(() => env.beforeSend(env))
|
|
19
16
|
.then(() => send(url, env));
|
package/src/js/util/animation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { attr } from './attr';
|
|
2
2
|
import { once, trigger } from './event';
|
|
3
3
|
import { css, propName } from './style';
|
|
4
|
-
import {
|
|
4
|
+
import { startsWith, toNodes } from './lang';
|
|
5
5
|
import { addClass, hasClass, removeClass, removeClasses } from './class';
|
|
6
6
|
|
|
7
7
|
export function transition(element, props, duration = 400, timing = 'linear') {
|
|
@@ -35,17 +35,12 @@ export function transition(element, props, duration = 400, timing = 'linear') {
|
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
addClass(element, 'uk-transition');
|
|
38
|
-
css(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
transitionTimingFunction: timing,
|
|
45
|
-
},
|
|
46
|
-
props
|
|
47
|
-
)
|
|
48
|
-
);
|
|
38
|
+
css(element, {
|
|
39
|
+
transitionProperty: Object.keys(props).map(propName).join(','),
|
|
40
|
+
transitionDuration: `${duration}ms`,
|
|
41
|
+
transitionTimingFunction: timing,
|
|
42
|
+
...props,
|
|
43
|
+
});
|
|
49
44
|
})
|
|
50
45
|
)
|
|
51
46
|
);
|
package/src/js/util/dom.js
CHANGED
|
@@ -12,6 +12,10 @@ export function ready(fn) {
|
|
|
12
12
|
once(document, 'DOMContentLoaded', fn);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export function isTag(element, tagName) {
|
|
16
|
+
return element?.tagName?.toLowerCase() === tagName.toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
export function empty(element) {
|
|
16
20
|
return replaceChildren(element, '');
|
|
17
21
|
}
|
|
@@ -20,34 +24,20 @@ export function html(parent, html) {
|
|
|
20
24
|
return isUndefined(html) ? $(parent).innerHTML : replaceChildren(parent, html);
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export function prepend(parent, element) {
|
|
30
|
-
const nodes = $$(element);
|
|
31
|
-
$(parent).prepend(...nodes);
|
|
32
|
-
return nodes;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function append(parent, element) {
|
|
36
|
-
const nodes = $$(element);
|
|
37
|
-
$(parent).append(...nodes);
|
|
38
|
-
return nodes;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function before(ref, element) {
|
|
42
|
-
const nodes = $$(element);
|
|
43
|
-
$(ref).before(...nodes);
|
|
44
|
-
return nodes;
|
|
45
|
-
}
|
|
27
|
+
export const replaceChildren = applyFn('replaceChildren');
|
|
28
|
+
export const prepend = applyFn('prepend');
|
|
29
|
+
export const append = applyFn('append');
|
|
30
|
+
export const before = applyFn('before');
|
|
31
|
+
export const after = applyFn('after');
|
|
46
32
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
function applyFn(fn) {
|
|
34
|
+
return function (ref, element) {
|
|
35
|
+
const nodes = toNodes(isString(element) ? fragment(element) : element);
|
|
36
|
+
if (nodes.length) {
|
|
37
|
+
$(ref)[fn](...nodes);
|
|
38
|
+
}
|
|
39
|
+
return unwrapSingle(nodes);
|
|
40
|
+
};
|
|
51
41
|
}
|
|
52
42
|
|
|
53
43
|
export function remove(element) {
|
|
@@ -85,9 +75,16 @@ export function unwrap(element) {
|
|
|
85
75
|
|
|
86
76
|
export function fragment(html) {
|
|
87
77
|
const template = document.createElement('template');
|
|
88
|
-
template.innerHTML = html;
|
|
89
|
-
const
|
|
90
|
-
|
|
78
|
+
template.innerHTML = html.trim();
|
|
79
|
+
const nodes = toNodes(template.content.childNodes);
|
|
80
|
+
for (const node of nodes) {
|
|
81
|
+
document.adoptNode(node);
|
|
82
|
+
}
|
|
83
|
+
return unwrapSingle(nodes);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function unwrapSingle(nodes) {
|
|
87
|
+
return nodes.length > 1 ? nodes : nodes[0];
|
|
91
88
|
}
|
|
92
89
|
|
|
93
90
|
export function apply(node, fn) {
|
package/src/js/util/lang.js
CHANGED
|
@@ -21,19 +21,19 @@ function toUpper(_, c) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function startsWith(str, search) {
|
|
24
|
-
return str
|
|
24
|
+
return str?.startsWith?.(search);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function endsWith(str, search) {
|
|
28
|
-
return str
|
|
28
|
+
return str?.endsWith?.(search);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function includes(obj, search) {
|
|
32
|
-
return obj
|
|
32
|
+
return obj?.includes?.(search);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export function findIndex(array, predicate) {
|
|
36
|
-
return array
|
|
36
|
+
return array?.findIndex?.(predicate);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export const { isArray, from: toArray } = Array;
|
|
@@ -128,8 +128,9 @@ export function toWindow(element) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
element = toNode(element);
|
|
131
|
+
const document = isDocument(element) ? element : element?.ownerDocument;
|
|
131
132
|
|
|
132
|
-
return
|
|
133
|
+
return document?.defaultView || window;
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
export function toMs(time) {
|
|
@@ -216,7 +217,7 @@ export const Dimensions = {
|
|
|
216
217
|
},
|
|
217
218
|
|
|
218
219
|
contain(dimensions, maxDimensions) {
|
|
219
|
-
dimensions =
|
|
220
|
+
dimensions = { ...dimensions };
|
|
220
221
|
|
|
221
222
|
each(
|
|
222
223
|
dimensions,
|
package/src/js/util/options.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assign,
|
|
3
|
-
hasOwn,
|
|
4
|
-
includes,
|
|
5
|
-
isArray,
|
|
6
|
-
isFunction,
|
|
7
|
-
isUndefined,
|
|
8
|
-
sortBy,
|
|
9
|
-
startsWith,
|
|
10
|
-
} from './lang';
|
|
1
|
+
import { hasOwn, includes, isArray, isFunction, isUndefined, sortBy, startsWith } from './lang';
|
|
11
2
|
|
|
12
3
|
const strats = {};
|
|
13
4
|
|
|
@@ -48,7 +39,7 @@ strats.props = function (parentVal, childVal) {
|
|
|
48
39
|
|
|
49
40
|
// extend strategy
|
|
50
41
|
strats.computed = strats.methods = function (parentVal, childVal) {
|
|
51
|
-
return childVal ? (parentVal ?
|
|
42
|
+
return childVal ? (parentVal ? { ...parentVal, ...childVal } : childVal) : parentVal;
|
|
52
43
|
};
|
|
53
44
|
|
|
54
45
|
// data strategy
|
package/src/js/util/player.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { isTag } from './dom';
|
|
1
2
|
import { once } from './event';
|
|
2
|
-
import {
|
|
3
|
+
import { includes, noop } from './lang';
|
|
3
4
|
|
|
4
5
|
export function play(el) {
|
|
5
6
|
if (isIFrame(el)) {
|
|
@@ -40,11 +41,11 @@ export function isVideo(el) {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
function isHTML5(el) {
|
|
43
|
-
return el
|
|
44
|
+
return isTag(el, 'video');
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
function isIFrame(el) {
|
|
47
|
-
return el
|
|
48
|
+
return isTag(el, 'iframe') && (isYoutube(el) || isVimeo(el));
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
function isYoutube(el) {
|
|
@@ -64,7 +65,7 @@ async function call(el, cmd) {
|
|
|
64
65
|
|
|
65
66
|
function post(el, cmd) {
|
|
66
67
|
try {
|
|
67
|
-
el.contentWindow.postMessage(JSON.stringify(
|
|
68
|
+
el.contentWindow.postMessage(JSON.stringify({ event: 'command', ...cmd }), '*');
|
|
68
69
|
} catch (e) {
|
|
69
70
|
// noop
|
|
70
71
|
}
|
package/src/js/util/selector.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { attr } from './attr';
|
|
2
|
-
import { inBrowser } from './env';
|
|
3
2
|
import { closest, index, matches, parent } from './filter';
|
|
4
3
|
import { isDocument, isString, memoize, toNode, toNodes } from './lang';
|
|
5
4
|
|
|
@@ -11,12 +10,6 @@ export function queryAll(selector, context) {
|
|
|
11
10
|
return findAll(selector, getContext(selector, context));
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
function getContext(selector, context = document) {
|
|
15
|
-
return (isString(selector) && isContextSelector(selector)) || isDocument(context)
|
|
16
|
-
? context
|
|
17
|
-
: context.ownerDocument;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
13
|
export function find(selector, context) {
|
|
21
14
|
return toNode(_query(selector, context, 'querySelector'));
|
|
22
15
|
}
|
|
@@ -25,6 +18,17 @@ export function findAll(selector, context) {
|
|
|
25
18
|
return toNodes(_query(selector, context, 'querySelectorAll'));
|
|
26
19
|
}
|
|
27
20
|
|
|
21
|
+
const contextSelectorRe = /(^|[^\\],)\s*[!>+~-]/;
|
|
22
|
+
const isContextSelector = memoize((selector) => selector.match(contextSelectorRe));
|
|
23
|
+
|
|
24
|
+
function getContext(selector, context = document) {
|
|
25
|
+
return (isString(selector) && isContextSelector(selector)) || isDocument(context)
|
|
26
|
+
? context
|
|
27
|
+
: context.ownerDocument;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const contextSanitizeRe = /([!>+~-])(?=\s+[!>+~-]|\s*$)/g;
|
|
31
|
+
|
|
28
32
|
function _query(selector, context = document, queryFn) {
|
|
29
33
|
if (!selector || !isString(selector)) {
|
|
30
34
|
return selector;
|
|
@@ -69,11 +73,6 @@ function _query(selector, context = document, queryFn) {
|
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
const contextSelectorRe = /(^|[^\\],)\s*[!>+~-]/;
|
|
73
|
-
const contextSanitizeRe = /([!>+~-])(?=\s+[!>+~-]|\s*$)/g;
|
|
74
|
-
|
|
75
|
-
const isContextSelector = memoize((selector) => selector.match(contextSelectorRe));
|
|
76
|
-
|
|
77
76
|
const selectorRe = /.*?[^\\](?:,|$)/g;
|
|
78
77
|
|
|
79
78
|
const splitSelector = memoize((selector) =>
|
|
@@ -99,11 +98,6 @@ function domPath(element) {
|
|
|
99
98
|
return names.join(' > ');
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
const escapeFn =
|
|
103
|
-
(inBrowser && window.CSS && CSS.escape) ||
|
|
104
|
-
function (css) {
|
|
105
|
-
return css.replace(/([^\x7f-\uFFFF\w-])/g, (match) => `\\${match}`);
|
|
106
|
-
};
|
|
107
101
|
export function escape(css) {
|
|
108
|
-
return isString(css) ?
|
|
102
|
+
return isString(css) ? CSS.escape(css) : '';
|
|
109
103
|
}
|
package/src/js/util/style.js
CHANGED
|
@@ -31,7 +31,8 @@ const cssNumber = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export function css(element, property, value, priority = '') {
|
|
34
|
-
|
|
34
|
+
const elements = toNodes(element);
|
|
35
|
+
for (const element of elements) {
|
|
35
36
|
if (isString(property)) {
|
|
36
37
|
property = propName(property);
|
|
37
38
|
|
|
@@ -57,9 +58,8 @@ export function css(element, property, value, priority = '') {
|
|
|
57
58
|
priority = value;
|
|
58
59
|
each(property, (value, property) => css(element, property, value, priority));
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})[0];
|
|
61
|
+
}
|
|
62
|
+
return elements[0];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function getStyles(element, pseudoElt) {
|