uikit 3.9.4 → 3.9.5-dev.605a9ce7d
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 +6 -0
- package/build/util.js +4 -1
- 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 +1 -1
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +1 -1
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +1 -1
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +1 -1
- 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 +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 +49 -43
- 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 +49 -43
- package/dist/js/uikit.min.js +1 -1
- package/package.json +1 -1
- package/src/js/core/img.js +49 -37
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.9.
|
|
5
|
+
"version": "3.9.5-dev.605a9ce7d",
|
|
6
6
|
"main": "dist/js/uikit.js",
|
|
7
7
|
"style": "dist/css/uikit.css",
|
|
8
8
|
"sideEffects": [
|
package/src/js/core/img.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import {createEvent, css, Dimensions, escape, getImage, includes, isUndefined, queryAll, startsWith, toFloat, toPx, trigger} from 'uikit-util';
|
|
1
|
+
import {attr, children, createEvent, css, data, Dimensions, escape, getImage, includes, isUndefined, once, parent, queryAll, startsWith, toFloat, toPx, trigger} from 'uikit-util';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
|
|
5
|
-
args: 'dataSrc',
|
|
6
|
-
|
|
7
5
|
props: {
|
|
8
|
-
dataSrc: String,
|
|
9
|
-
dataSrcset: Boolean,
|
|
10
|
-
sizes: String,
|
|
11
6
|
width: Number,
|
|
12
7
|
height: Number,
|
|
13
8
|
offsetTop: String,
|
|
@@ -16,9 +11,6 @@ export default {
|
|
|
16
11
|
},
|
|
17
12
|
|
|
18
13
|
data: {
|
|
19
|
-
dataSrc: '',
|
|
20
|
-
dataSrcset: false,
|
|
21
|
-
sizes: false,
|
|
22
14
|
width: false,
|
|
23
15
|
height: false,
|
|
24
16
|
offsetTop: '50vh',
|
|
@@ -28,8 +20,8 @@ export default {
|
|
|
28
20
|
|
|
29
21
|
computed: {
|
|
30
22
|
|
|
31
|
-
cacheKey(
|
|
32
|
-
return `${this.$name}.${
|
|
23
|
+
cacheKey() {
|
|
24
|
+
return `${this.$name}.${data(this.$el, 'data-src')}`;
|
|
33
25
|
},
|
|
34
26
|
|
|
35
27
|
width({width, dataWidth}) {
|
|
@@ -40,14 +32,6 @@ export default {
|
|
|
40
32
|
return height || dataHeight;
|
|
41
33
|
},
|
|
42
34
|
|
|
43
|
-
sizes({sizes, dataSizes}) {
|
|
44
|
-
return sizes || dataSizes;
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
isImg(_, $el) {
|
|
48
|
-
return isImg($el);
|
|
49
|
-
},
|
|
50
|
-
|
|
51
35
|
target: {
|
|
52
36
|
|
|
53
37
|
get({target}) {
|
|
@@ -73,14 +57,14 @@ export default {
|
|
|
73
57
|
connected() {
|
|
74
58
|
|
|
75
59
|
if (!window.IntersectionObserver) {
|
|
76
|
-
setSrcAttrs(this.$el
|
|
60
|
+
setSrcAttrs(this.$el);
|
|
77
61
|
return;
|
|
78
62
|
}
|
|
79
63
|
|
|
80
64
|
if (storage[this.cacheKey]) {
|
|
81
|
-
setSrcAttrs(this.$el, storage[this.cacheKey]
|
|
82
|
-
} else if (this
|
|
83
|
-
|
|
65
|
+
setSrcAttrs(this.$el, storage[this.cacheKey]);
|
|
66
|
+
} else if (isImg(this.$el) && this.width && this.height) {
|
|
67
|
+
attr(this.$el, 'src', getPlaceholderImage(this.$el));
|
|
84
68
|
}
|
|
85
69
|
|
|
86
70
|
this.observer = new IntersectionObserver(this.load, {
|
|
@@ -107,7 +91,7 @@ export default {
|
|
|
107
91
|
this.load(this.observer.takeRecords());
|
|
108
92
|
}
|
|
109
93
|
|
|
110
|
-
if (this
|
|
94
|
+
if (isImg(this.$el)) {
|
|
111
95
|
return false;
|
|
112
96
|
}
|
|
113
97
|
|
|
@@ -115,14 +99,15 @@ export default {
|
|
|
115
99
|
|
|
116
100
|
},
|
|
117
101
|
|
|
118
|
-
write(
|
|
102
|
+
write(store) {
|
|
119
103
|
|
|
120
|
-
|
|
104
|
+
const srcset = data(this.$el, 'data-srcset');
|
|
105
|
+
if (srcset && window.devicePixelRatio !== 1) {
|
|
121
106
|
|
|
122
107
|
const bgSize = css(this.$el, 'backgroundSize');
|
|
123
|
-
if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) ===
|
|
124
|
-
|
|
125
|
-
css(this.$el, 'backgroundSize', `${
|
|
108
|
+
if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === store.bgSize) {
|
|
109
|
+
store.bgSize = getSourceSize(srcset, data(this.$el, 'sizes'));
|
|
110
|
+
css(this.$el, 'backgroundSize', `${store.bgSize}px`);
|
|
126
111
|
}
|
|
127
112
|
|
|
128
113
|
}
|
|
@@ -142,9 +127,9 @@ export default {
|
|
|
142
127
|
return;
|
|
143
128
|
}
|
|
144
129
|
|
|
145
|
-
this._data.image =
|
|
130
|
+
this._data.image = getImageFromElement(this.$el).then(img => {
|
|
146
131
|
|
|
147
|
-
setSrcAttrs(this.$el, currentSrc(img)
|
|
132
|
+
setSrcAttrs(this.$el, currentSrc(img));
|
|
148
133
|
storage[this.cacheKey] = currentSrc(img);
|
|
149
134
|
return img;
|
|
150
135
|
|
|
@@ -163,13 +148,19 @@ export default {
|
|
|
163
148
|
|
|
164
149
|
};
|
|
165
150
|
|
|
166
|
-
|
|
151
|
+
const srcProps = ['data-src', 'data-srcset', 'sizes'];
|
|
152
|
+
function setSrcAttrs(el, src) {
|
|
167
153
|
|
|
154
|
+
const parentNode = parent(el);
|
|
168
155
|
if (isImg(el)) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
156
|
+
(isPicture(parentNode) ? children(parentNode) : [el]).forEach(el =>
|
|
157
|
+
srcProps.forEach(prop => {
|
|
158
|
+
const value = data(el, prop);
|
|
159
|
+
if (value) {
|
|
160
|
+
attr(el, prop.replace(/^(data-)+/, ''), value);
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
);
|
|
173
164
|
} else if (src) {
|
|
174
165
|
|
|
175
166
|
const change = !includes(el.style.backgroundImage, src);
|
|
@@ -207,6 +198,19 @@ function sizesToPixel(sizes) {
|
|
|
207
198
|
return matches || '100vw';
|
|
208
199
|
}
|
|
209
200
|
|
|
201
|
+
function getImageFromElement(el) {
|
|
202
|
+
const parentNode = parent(el);
|
|
203
|
+
if (!isPicture(parentNode)) {
|
|
204
|
+
return getImage(...srcProps.map(prop => data(el, prop)));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return new Promise((resolve, reject) => {
|
|
208
|
+
const picture = parentNode.cloneNode(true);
|
|
209
|
+
once(picture, 'load error', e => e.type === 'error' ? reject(e) : resolve(e.target), true);
|
|
210
|
+
setSrcAttrs(el);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
210
214
|
const sizeRe = /\d+(?:\w+|%)/g;
|
|
211
215
|
const additionRe = /[+-]?(\d+)/g;
|
|
212
216
|
function evaluateSize(size) {
|
|
@@ -228,8 +232,16 @@ function getSourceSize(srcset, sizes) {
|
|
|
228
232
|
return descriptors.filter(size => size >= srcSize)[0] || descriptors.pop() || '';
|
|
229
233
|
}
|
|
230
234
|
|
|
235
|
+
function isPicture(el) {
|
|
236
|
+
return isA(el, 'PICTURE');
|
|
237
|
+
}
|
|
238
|
+
|
|
231
239
|
function isImg(el) {
|
|
232
|
-
return el
|
|
240
|
+
return isA(el, 'IMG');
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function isA(el, tagName) {
|
|
244
|
+
return el && el.tagName === tagName;
|
|
233
245
|
}
|
|
234
246
|
|
|
235
247
|
function currentSrc(el) {
|