free-astro-components 1.1.0 → 1.1.1
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/package.json +1 -1
- package/src/utils/utils.ts +11 -7
package/package.json
CHANGED
package/src/utils/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
let lastWidth
|
|
1
|
+
let lastWidth: number;
|
|
2
2
|
|
|
3
3
|
export const DOMLoaded = (callback: () => void) => {
|
|
4
4
|
if (document.readyState === 'loading') {
|
|
@@ -31,12 +31,16 @@ export const isTouchDevice = () => {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export const hasViewportWidthChanged = (): boolean => {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
if (typeof window !== 'undefined') {
|
|
35
|
+
const currentWidth = window.innerWidth;
|
|
36
|
+
const widthChanged = currentWidth !== lastWidth;
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
if (widthChanged) {
|
|
39
|
+
lastWidth = currentWidth;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return widthChanged;
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
return
|
|
42
|
-
}
|
|
45
|
+
return false;
|
|
46
|
+
};
|