uikit 3.11.1 → 3.11.2-dev.28b7953b9
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 +29 -0
- 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 +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 +1 -1
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +1 -1
- 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 +37 -41
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +32 -25
- 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 +32 -25
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +36 -1
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +2 -3
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +1 -1
- 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 +285 -224
- 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 +383 -292
- package/dist/js/uikit.min.js +1 -1
- package/package.json +1 -1
- package/src/js/api/component.js +1 -1
- package/src/js/api/state.js +20 -24
- package/src/js/components/parallax.js +5 -16
- package/src/js/components/slider.js +1 -1
- package/src/js/components/slideshow.js +32 -1
- package/src/js/components/sortable.js +1 -2
- package/src/js/core/core.js +2 -2
- package/src/js/core/drop.js +1 -1
- package/src/js/core/height-viewport.js +2 -2
- package/src/js/core/img.js +114 -98
- package/src/js/core/navbar.js +6 -2
- package/src/js/core/sticky.js +82 -50
- package/src/js/mixin/parallax.js +32 -21
- package/src/js/util/dimensions.js +28 -12
- package/src/js/util/fastdom.js +2 -2
- package/src/js/util/options.js +4 -4
- package/src/js/util/viewport.js +7 -3
- package/tests/image.html +31 -41
- package/tests/images/test.avif +0 -0
- package/tests/images/test.webp +0 -0
- package/tests/sticky-parallax.html +44 -41
- package/tests/sticky.html +56 -24
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.11.
|
|
5
|
+
"version": "3.11.2-dev.28b7953b9",
|
|
6
6
|
"main": "dist/js/uikit.js",
|
|
7
7
|
"style": "dist/css/uikit.css",
|
|
8
8
|
"sideEffects": [
|
package/src/js/api/component.js
CHANGED
|
@@ -28,7 +28,7 @@ export default function (UIkit) {
|
|
|
28
28
|
|
|
29
29
|
return component.options.functional
|
|
30
30
|
? new component({data: isPlainObject(element) ? element : [...arguments]})
|
|
31
|
-
:
|
|
31
|
+
: element ? $$(element).map(init)[0] : init();
|
|
32
32
|
|
|
33
33
|
function init(element) {
|
|
34
34
|
|
package/src/js/api/state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {assign, camelize, data as getData, hasOwn, hyphenate, isArray,
|
|
1
|
+
import {assign, camelize, data as getData, hasOwn, hyphenate, isArray, isFunction, isNumeric, isPlainObject, isString, isUndefined, mergeOptions, on, parseOptions, startsWith, toBoolean, toNumber} from 'uikit-util';
|
|
2
2
|
|
|
3
3
|
export default function (UIkit) {
|
|
4
4
|
|
|
@@ -211,11 +211,11 @@ export default function (UIkit) {
|
|
|
211
211
|
on(
|
|
212
212
|
el,
|
|
213
213
|
name,
|
|
214
|
-
|
|
215
|
-
?
|
|
216
|
-
: isString(delegate)
|
|
214
|
+
delegate
|
|
215
|
+
? isString(delegate)
|
|
217
216
|
? delegate
|
|
218
|
-
: delegate.call(component)
|
|
217
|
+
: delegate.call(component)
|
|
218
|
+
: null,
|
|
219
219
|
isString(handler) ? component[handler] : handler.bind(component),
|
|
220
220
|
{passive, capture, self}
|
|
221
221
|
)
|
|
@@ -250,27 +250,23 @@ export default function (UIkit) {
|
|
|
250
250
|
: [value];
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
function normalizeData({data}, {args, props = {}}) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
assign(data, value);
|
|
259
|
-
} else {
|
|
260
|
-
data[args[index]] = value;
|
|
261
|
-
}
|
|
262
|
-
return data;
|
|
263
|
-
}, {})
|
|
264
|
-
: undefined
|
|
265
|
-
: data;
|
|
266
|
-
|
|
267
|
-
if (data) {
|
|
268
|
-
for (const key in data) {
|
|
269
|
-
if (isUndefined(data[key])) {
|
|
270
|
-
delete data[key];
|
|
253
|
+
function normalizeData({data = {}}, {args = [], props = {}}) {
|
|
254
|
+
if (isArray(data)) {
|
|
255
|
+
data = data.slice(0, args.length).reduce((data, value, index) => {
|
|
256
|
+
if (isPlainObject(value)) {
|
|
257
|
+
assign(data, value);
|
|
271
258
|
} else {
|
|
272
|
-
data[
|
|
259
|
+
data[args[index]] = value;
|
|
273
260
|
}
|
|
261
|
+
return data;
|
|
262
|
+
}, {});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
for (const key in data) {
|
|
266
|
+
if (isUndefined(data[key])) {
|
|
267
|
+
delete data[key];
|
|
268
|
+
} else if (props[key]) {
|
|
269
|
+
data[key] = coerce(props[key], data[key]);
|
|
274
270
|
}
|
|
275
271
|
}
|
|
276
272
|
|
|
@@ -28,13 +28,15 @@ export default {
|
|
|
28
28
|
},
|
|
29
29
|
|
|
30
30
|
start({start}) {
|
|
31
|
-
return
|
|
31
|
+
return toPx(start, 'height', this.target, true);
|
|
32
32
|
},
|
|
33
33
|
|
|
34
34
|
end({end, viewport}) {
|
|
35
|
-
return
|
|
35
|
+
return toPx(
|
|
36
36
|
end || (viewport = (1 - viewport) * 100) && `${viewport}vh+${viewport}%`,
|
|
37
|
-
|
|
37
|
+
'height',
|
|
38
|
+
this.target,
|
|
39
|
+
true
|
|
38
40
|
);
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -77,19 +79,6 @@ export default {
|
|
|
77
79
|
|
|
78
80
|
};
|
|
79
81
|
|
|
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
82
|
function ease(percent, easing) {
|
|
94
83
|
return easing >= 0
|
|
95
84
|
? Math.pow(percent, easing + 1)
|
|
@@ -30,7 +30,7 @@ export default {
|
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
finite({finite}) {
|
|
33
|
-
return finite || Math.ceil(getWidth(this.list)) < dimensions(this.list).width + getMaxElWidth(this.list) + this.center;
|
|
33
|
+
return finite || Math.ceil(getWidth(this.list)) < Math.floor(dimensions(this.list).width + getMaxElWidth(this.list) + this.center);
|
|
34
34
|
},
|
|
35
35
|
|
|
36
36
|
maxIndex() {
|
|
@@ -2,7 +2,7 @@ import Class from '../mixin/class';
|
|
|
2
2
|
import Slideshow from '../mixin/slideshow';
|
|
3
3
|
import Animations from './internal/slideshow-animations';
|
|
4
4
|
import SliderReactive from '../mixin/slider-reactive';
|
|
5
|
-
import {boxModelAdjust, css} from 'uikit-util';
|
|
5
|
+
import {$$, boxModelAdjust, css, isVisible} from 'uikit-util';
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
|
|
@@ -24,6 +24,29 @@ export default {
|
|
|
24
24
|
Animations
|
|
25
25
|
},
|
|
26
26
|
|
|
27
|
+
connected() {
|
|
28
|
+
if (window.IntersectionObserver) {
|
|
29
|
+
this.observer = new IntersectionObserver(entries => {
|
|
30
|
+
if (entries.some(entry => entry.isIntersecting)) {
|
|
31
|
+
this.preloadSlides();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
this.observer.observe(this.$el);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
disconnected() {
|
|
39
|
+
this.observer && this.observer.disconnect();
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
methods: {
|
|
43
|
+
|
|
44
|
+
preloadSlides() {
|
|
45
|
+
[1, -1].forEach(i => removeLazyLoad(this.slides[this.getIndex(this.index + i)]));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
},
|
|
49
|
+
|
|
27
50
|
update: {
|
|
28
51
|
|
|
29
52
|
read() {
|
|
@@ -44,6 +67,10 @@ export default {
|
|
|
44
67
|
height = Math.min(this.maxHeight, height);
|
|
45
68
|
}
|
|
46
69
|
|
|
70
|
+
if (isVisible(this.$el)) {
|
|
71
|
+
this.preloadSlides();
|
|
72
|
+
}
|
|
73
|
+
|
|
47
74
|
return {height: height - boxModelAdjust(this.list, 'height', 'content-box')};
|
|
48
75
|
},
|
|
49
76
|
|
|
@@ -56,3 +83,7 @@ export default {
|
|
|
56
83
|
}
|
|
57
84
|
|
|
58
85
|
};
|
|
86
|
+
|
|
87
|
+
function removeLazyLoad(el) {
|
|
88
|
+
el && $$('img[loading="lazy"]', el).forEach(el => el.loading = 'eager');
|
|
89
|
+
}
|
|
@@ -218,7 +218,6 @@ export default {
|
|
|
218
218
|
|
|
219
219
|
off(document, pointerMove, this.move);
|
|
220
220
|
off(document, pointerUp, this.end);
|
|
221
|
-
off(window, 'scroll', this.scroll);
|
|
222
221
|
|
|
223
222
|
if (!this.drag) {
|
|
224
223
|
return;
|
|
@@ -295,7 +294,7 @@ function trackScroll(pos) {
|
|
|
295
294
|
trackTimer = setInterval(() => {
|
|
296
295
|
|
|
297
296
|
let {x, y} = pos;
|
|
298
|
-
y += window
|
|
297
|
+
y += scrollTop(window);
|
|
299
298
|
|
|
300
299
|
const dist = (Date.now() - last) * .3;
|
|
301
300
|
last = Date.now();
|
package/src/js/core/core.js
CHANGED
|
@@ -13,7 +13,7 @@ export default function (UIkit) {
|
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
pendingResize = true;
|
|
16
|
-
fastdom.
|
|
16
|
+
fastdom.read(() => pendingResize = false);
|
|
17
17
|
UIkit.update(null, 'resize');
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -32,7 +32,7 @@ export default function (UIkit) {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
pending = true;
|
|
35
|
-
fastdom.
|
|
35
|
+
fastdom.read(() => pending = false);
|
|
36
36
|
|
|
37
37
|
UIkit.update(null, e.type);
|
|
38
38
|
|
package/src/js/core/drop.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FlexBug from '../mixin/flex-bug';
|
|
2
|
-
import {boxModelAdjust, css, dimensions, endsWith, height, isNumeric, isString, isVisible, offset, query, toFloat} from 'uikit-util';
|
|
2
|
+
import {boxModelAdjust, css, dimensions, endsWith, height, isNumeric, isString, isVisible, offset, query, toFloat, trigger} from 'uikit-util';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
|
|
@@ -76,7 +76,7 @@ export default {
|
|
|
76
76
|
css(this.$el, {minHeight});
|
|
77
77
|
|
|
78
78
|
if (minHeight !== prev) {
|
|
79
|
-
|
|
79
|
+
trigger(this.$el, 'resize');
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
if (this.minHeight && toFloat(css(this.$el, 'minHeight')) < this.minHeight) {
|
package/src/js/core/img.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {createEvent, css,
|
|
1
|
+
import {append, attr, children, createEvent, css, data, escape, fragment, hasAttr, includes, isArray, isEmpty, parent, parseOptions, queryAll, startsWith, toFloat, toPx, trigger} from 'uikit-util';
|
|
2
|
+
|
|
3
|
+
const nativeLazyLoad = 'loading' in HTMLImageElement.prototype;
|
|
4
|
+
const nativeIsIntersecting = 'isIntersecting' in IntersectionObserverEntry.prototype; // Old chromium based browsers (UC Browser) did not implement `isIntersecting`
|
|
2
5
|
|
|
3
6
|
export default {
|
|
4
7
|
|
|
@@ -6,10 +9,7 @@ export default {
|
|
|
6
9
|
|
|
7
10
|
props: {
|
|
8
11
|
dataSrc: String,
|
|
9
|
-
|
|
10
|
-
sizes: String,
|
|
11
|
-
width: Number,
|
|
12
|
-
height: Number,
|
|
12
|
+
dataSources: String,
|
|
13
13
|
offsetTop: String,
|
|
14
14
|
offsetLeft: String,
|
|
15
15
|
target: String
|
|
@@ -17,10 +17,7 @@ export default {
|
|
|
17
17
|
|
|
18
18
|
data: {
|
|
19
19
|
dataSrc: '',
|
|
20
|
-
|
|
21
|
-
sizes: false,
|
|
22
|
-
width: false,
|
|
23
|
-
height: false,
|
|
20
|
+
dataSources: [],
|
|
24
21
|
offsetTop: '50vh',
|
|
25
22
|
offsetLeft: '50vw',
|
|
26
23
|
target: false
|
|
@@ -28,26 +25,6 @@ export default {
|
|
|
28
25
|
|
|
29
26
|
computed: {
|
|
30
27
|
|
|
31
|
-
cacheKey({dataSrc}) {
|
|
32
|
-
return `${this.$name}.${dataSrc}`;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
width({width, dataWidth}) {
|
|
36
|
-
return width || dataWidth;
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
height({height, dataHeight}) {
|
|
40
|
-
return height || dataHeight;
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
sizes({sizes, dataSizes}) {
|
|
44
|
-
return sizes || dataSizes;
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
isImg(_, $el) {
|
|
48
|
-
return isImg($el);
|
|
49
|
-
},
|
|
50
|
-
|
|
51
28
|
target: {
|
|
52
29
|
|
|
53
30
|
get({target}) {
|
|
@@ -58,36 +35,31 @@ export default {
|
|
|
58
35
|
this.observe();
|
|
59
36
|
}
|
|
60
37
|
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
offsetTop({offsetTop}) {
|
|
64
|
-
return toPx(offsetTop, 'height');
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
offsetLeft({offsetLeft}) {
|
|
68
|
-
return toPx(offsetLeft, 'width');
|
|
69
38
|
}
|
|
70
39
|
|
|
71
40
|
},
|
|
72
41
|
|
|
73
42
|
connected() {
|
|
74
43
|
|
|
75
|
-
if (!window.IntersectionObserver) {
|
|
76
|
-
setSrcAttrs(this.$el, this.dataSrc
|
|
44
|
+
if (!window.IntersectionObserver || !nativeIsIntersecting) {
|
|
45
|
+
setSrcAttrs(this.$el, this.dataSrc);
|
|
77
46
|
return;
|
|
78
47
|
}
|
|
79
48
|
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
49
|
+
if (nativeLazyLoad && isImg(this.$el)) {
|
|
50
|
+
this.$el.loading = 'lazy';
|
|
51
|
+
setSrcAttrs(this.$el);
|
|
52
|
+
|
|
53
|
+
if (this.target.length === 1) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
84
56
|
}
|
|
85
57
|
|
|
86
|
-
|
|
87
|
-
rootMargin: `${this.offsetTop}px ${this.offsetLeft}px`
|
|
88
|
-
});
|
|
58
|
+
ensureSrcAttribute(this.$el);
|
|
89
59
|
|
|
90
|
-
|
|
60
|
+
const rootMargin = `${toPx(this.offsetTop, 'height')}px ${toPx(this.offsetLeft, 'width')}px`;
|
|
61
|
+
this.observer = new IntersectionObserver(this.load, {rootMargin});
|
|
62
|
+
this.observe();
|
|
91
63
|
|
|
92
64
|
},
|
|
93
65
|
|
|
@@ -97,32 +69,17 @@ export default {
|
|
|
97
69
|
|
|
98
70
|
update: {
|
|
99
71
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (!this.observer) {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (!image && document.readyState === 'complete') {
|
|
107
|
-
this.load(this.observer.takeRecords());
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (this.isImg) {
|
|
72
|
+
write(store) {
|
|
73
|
+
if (!this.observer || isImg(this.$el)) {
|
|
111
74
|
return false;
|
|
112
75
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
write(data) {
|
|
119
|
-
|
|
120
|
-
if (this.dataSrcset && window.devicePixelRatio !== 1) {
|
|
76
|
+
const srcset = data(this.$el, 'data-srcset');
|
|
77
|
+
if (srcset && window.devicePixelRatio !== 1) {
|
|
121
78
|
|
|
122
79
|
const bgSize = css(this.$el, 'backgroundSize');
|
|
123
|
-
if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) ===
|
|
124
|
-
|
|
125
|
-
css(this.$el, 'backgroundSize', `${
|
|
80
|
+
if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === store.bgSize) {
|
|
81
|
+
store.bgSize = getSourceSize(srcset, data(this.$el, 'sizes'));
|
|
82
|
+
css(this.$el, 'backgroundSize', `${store.bgSize}px`);
|
|
126
83
|
}
|
|
127
84
|
|
|
128
85
|
}
|
|
@@ -137,18 +94,25 @@ export default {
|
|
|
137
94
|
|
|
138
95
|
load(entries) {
|
|
139
96
|
|
|
140
|
-
|
|
141
|
-
if (!entries.some(entry => isUndefined(entry.isIntersecting) || entry.isIntersecting)) {
|
|
97
|
+
if (!entries.some(entry => entry.isIntersecting)) {
|
|
142
98
|
return;
|
|
143
99
|
}
|
|
144
100
|
|
|
145
|
-
this._data.image
|
|
101
|
+
if (this._data.image) {
|
|
102
|
+
return this._data.image;
|
|
103
|
+
}
|
|
146
104
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
105
|
+
const image = isImg(this.$el)
|
|
106
|
+
? this.$el
|
|
107
|
+
: getImageFromElement(
|
|
108
|
+
this.$el,
|
|
109
|
+
this.dataSrc,
|
|
110
|
+
this.dataSources
|
|
111
|
+
);
|
|
150
112
|
|
|
151
|
-
|
|
113
|
+
this._data.image = image;
|
|
114
|
+
image.loading = 'eager';
|
|
115
|
+
setSrcAttrs(this.$el, image.currentSrc);
|
|
152
116
|
|
|
153
117
|
this.observer.disconnect();
|
|
154
118
|
},
|
|
@@ -163,13 +127,14 @@ export default {
|
|
|
163
127
|
|
|
164
128
|
};
|
|
165
129
|
|
|
166
|
-
function setSrcAttrs(el, src
|
|
130
|
+
function setSrcAttrs(el, src) {
|
|
167
131
|
|
|
168
132
|
if (isImg(el)) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
133
|
+
|
|
134
|
+
const parentNode = parent(el);
|
|
135
|
+
const elements = isPicture(parentNode) ? children(parentNode) : [el];
|
|
136
|
+
elements.forEach(el => setSourceProps(el, el));
|
|
137
|
+
|
|
173
138
|
} else if (src) {
|
|
174
139
|
|
|
175
140
|
const change = !includes(el.style.backgroundImage, src);
|
|
@@ -182,13 +147,66 @@ function setSrcAttrs(el, src, srcset, sizes) {
|
|
|
182
147
|
|
|
183
148
|
}
|
|
184
149
|
|
|
185
|
-
|
|
150
|
+
const srcProps = ['data-src', 'data-srcset', 'sizes'];
|
|
151
|
+
function setSourceProps(sourceEl, targetEl) {
|
|
152
|
+
srcProps.forEach(prop => {
|
|
153
|
+
const value = data(sourceEl, prop);
|
|
154
|
+
if (value) {
|
|
155
|
+
attr(targetEl, prop.replace(/^(data-)+/, ''), value);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function getImageFromElement(el, src, sources) {
|
|
161
|
+
|
|
162
|
+
if (!src) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const img = new Image();
|
|
167
|
+
|
|
168
|
+
wrapInPicture(img, sources);
|
|
169
|
+
setSourceProps(el, img);
|
|
170
|
+
img.onload = () => setSrcAttrs(el, img.currentSrc);
|
|
171
|
+
attr(img, 'src', src);
|
|
172
|
+
return img;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function wrapInPicture(img, sources) {
|
|
186
176
|
|
|
187
|
-
|
|
188
|
-
|
|
177
|
+
sources = parseSources(sources);
|
|
178
|
+
|
|
179
|
+
if (sources.length) {
|
|
180
|
+
const picture = fragment('<picture>');
|
|
181
|
+
sources.forEach(attrs => {
|
|
182
|
+
const source = fragment('<source>');
|
|
183
|
+
attr(source, attrs);
|
|
184
|
+
append(picture, source);
|
|
185
|
+
});
|
|
186
|
+
append(picture, img);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function parseSources(sources) {
|
|
191
|
+
if (!sources) {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (startsWith(sources, '[')) {
|
|
196
|
+
try {
|
|
197
|
+
sources = JSON.parse(sources);
|
|
198
|
+
} catch (e) {
|
|
199
|
+
sources = [];
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
sources = parseOptions(sources);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (!isArray(sources)) {
|
|
206
|
+
sources = [sources];
|
|
189
207
|
}
|
|
190
208
|
|
|
191
|
-
return
|
|
209
|
+
return sources.filter(source => !isEmpty(source));
|
|
192
210
|
}
|
|
193
211
|
|
|
194
212
|
const sizesRe = /\s*(.*?)\s*(\w+|calc\(.*?\))\s*(?:,|$)/g;
|
|
@@ -228,22 +246,20 @@ function getSourceSize(srcset, sizes) {
|
|
|
228
246
|
return descriptors.filter(size => size >= srcSize)[0] || descriptors.pop() || '';
|
|
229
247
|
}
|
|
230
248
|
|
|
231
|
-
function
|
|
232
|
-
|
|
249
|
+
function ensureSrcAttribute(el) {
|
|
250
|
+
if (isImg(el) && !hasAttr(el, 'src')) {
|
|
251
|
+
attr(el, 'src', 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"></svg>');
|
|
252
|
+
}
|
|
233
253
|
}
|
|
234
254
|
|
|
235
|
-
function
|
|
236
|
-
return el
|
|
255
|
+
function isPicture(el) {
|
|
256
|
+
return isA(el, 'PICTURE');
|
|
237
257
|
}
|
|
238
258
|
|
|
239
|
-
|
|
240
|
-
|
|
259
|
+
function isImg(el) {
|
|
260
|
+
return isA(el, 'IMG');
|
|
261
|
+
}
|
|
241
262
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
storage = window.sessionStorage || {};
|
|
245
|
-
storage[key] = 1;
|
|
246
|
-
delete storage[key];
|
|
247
|
-
} catch (e) {
|
|
248
|
-
storage = {};
|
|
263
|
+
function isA(el, tagName) {
|
|
264
|
+
return el && el.tagName === tagName;
|
|
249
265
|
}
|
package/src/js/core/navbar.js
CHANGED
|
@@ -137,7 +137,7 @@ export default {
|
|
|
137
137
|
|
|
138
138
|
handler({current}) {
|
|
139
139
|
const active = this.getActive();
|
|
140
|
-
if (active && includes(active.mode, 'hover') && active.target && !within(active.target, current) && !active.
|
|
140
|
+
if (active && includes(active.mode, 'hover') && active.target && !within(active.target, current) && !active.isDelaying) {
|
|
141
141
|
active.hide(false);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -301,7 +301,11 @@ export default {
|
|
|
301
301
|
|
|
302
302
|
const active = this.getActive();
|
|
303
303
|
|
|
304
|
-
if (matches(this.dropbar, ':hover')
|
|
304
|
+
if (matches(this.dropbar, ':hover')
|
|
305
|
+
&& active
|
|
306
|
+
&& active.$el === $el
|
|
307
|
+
&& !this.toggles.some(el => active.target !== el && matches(el, ':focus'))
|
|
308
|
+
) {
|
|
305
309
|
e.preventDefault();
|
|
306
310
|
}
|
|
307
311
|
}
|