@micromag/core 0.3.812 → 0.3.813
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/es/hooks.js +22 -8
- package/lib/hooks.js +22 -8
- package/package.json +2 -2
package/es/hooks.js
CHANGED
|
@@ -2144,20 +2144,34 @@ function useSpringValue(wantedProgress, immediate, params) {
|
|
|
2144
2144
|
return immediate ? wantedProgress : progress;
|
|
2145
2145
|
}
|
|
2146
2146
|
|
|
2147
|
-
function
|
|
2148
|
-
|
|
2149
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
2150
|
-
supportsWebp = _useState2[0],
|
|
2151
|
-
setSupportsWebp = _useState2[1];
|
|
2152
|
-
useEffect(function () {
|
|
2147
|
+
function checkWebpSupport() {
|
|
2148
|
+
return new Promise(function (resolve) {
|
|
2153
2149
|
var img = document.createElement('img');
|
|
2154
2150
|
img.onload = function () {
|
|
2155
|
-
|
|
2151
|
+
resolve(img.width > 0 && img.height > 0);
|
|
2156
2152
|
};
|
|
2157
2153
|
img.onerror = function () {
|
|
2158
|
-
|
|
2154
|
+
resolve(false);
|
|
2159
2155
|
};
|
|
2160
2156
|
img.src = 'data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoCAAEAAQAcJaQAA3AA/v3AgAA=';
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
function useSupportsWebp() {
|
|
2160
|
+
var defaultValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
2161
|
+
var _useState = useState(defaultValue),
|
|
2162
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2163
|
+
supportsWebp = _useState2[0],
|
|
2164
|
+
setSupportsWebp = _useState2[1];
|
|
2165
|
+
useEffect(function () {
|
|
2166
|
+
var canceled = false;
|
|
2167
|
+
checkWebpSupport().then(function (newSupport) {
|
|
2168
|
+
if (!canceled && newSupport !== supportsWebp) {
|
|
2169
|
+
setSupportsWebp(newSupport);
|
|
2170
|
+
}
|
|
2171
|
+
});
|
|
2172
|
+
return function () {
|
|
2173
|
+
canceled = true;
|
|
2174
|
+
};
|
|
2161
2175
|
}, []);
|
|
2162
2176
|
return supportsWebp;
|
|
2163
2177
|
}
|
package/lib/hooks.js
CHANGED
|
@@ -2146,20 +2146,34 @@ function useSpringValue(wantedProgress, immediate, params) {
|
|
|
2146
2146
|
return immediate ? wantedProgress : progress;
|
|
2147
2147
|
}
|
|
2148
2148
|
|
|
2149
|
-
function
|
|
2150
|
-
|
|
2151
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
2152
|
-
supportsWebp = _useState2[0],
|
|
2153
|
-
setSupportsWebp = _useState2[1];
|
|
2154
|
-
react.useEffect(function () {
|
|
2149
|
+
function checkWebpSupport() {
|
|
2150
|
+
return new Promise(function (resolve) {
|
|
2155
2151
|
var img = document.createElement('img');
|
|
2156
2152
|
img.onload = function () {
|
|
2157
|
-
|
|
2153
|
+
resolve(img.width > 0 && img.height > 0);
|
|
2158
2154
|
};
|
|
2159
2155
|
img.onerror = function () {
|
|
2160
|
-
|
|
2156
|
+
resolve(false);
|
|
2161
2157
|
};
|
|
2162
2158
|
img.src = 'data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoCAAEAAQAcJaQAA3AA/v3AgAA=';
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
function useSupportsWebp() {
|
|
2162
|
+
var defaultValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
2163
|
+
var _useState = react.useState(defaultValue),
|
|
2164
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2165
|
+
supportsWebp = _useState2[0],
|
|
2166
|
+
setSupportsWebp = _useState2[1];
|
|
2167
|
+
react.useEffect(function () {
|
|
2168
|
+
var canceled = false;
|
|
2169
|
+
checkWebpSupport().then(function (newSupport) {
|
|
2170
|
+
if (!canceled && newSupport !== supportsWebp) {
|
|
2171
|
+
setSupportsWebp(newSupport);
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
return function () {
|
|
2175
|
+
canceled = true;
|
|
2176
|
+
};
|
|
2163
2177
|
}, []);
|
|
2164
2178
|
return supportsWebp;
|
|
2165
2179
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.813",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
"access": "public",
|
|
168
168
|
"registry": "https://registry.npmjs.org/"
|
|
169
169
|
},
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "24f52ddea5f0ee918f594af86c3c8fd2e1b6f289"
|
|
171
171
|
}
|