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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/utils/utils.ts +11 -7
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A collection of free Astro components",
4
4
  "author": "Denis Ventura",
5
5
  "type": "module",
6
- "version": "1.1.0",
6
+ "version": "1.1.1",
7
7
  "exports": {
8
8
  ".": {
9
9
  "import": {
@@ -1,4 +1,4 @@
1
- let lastWidth = window.innerWidth
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
- const currentWidth = window.innerWidth
35
- const widthChanged = currentWidth !== lastWidth
34
+ if (typeof window !== 'undefined') {
35
+ const currentWidth = window.innerWidth;
36
+ const widthChanged = currentWidth !== lastWidth;
36
37
 
37
- if (widthChanged) {
38
- lastWidth = currentWidth
38
+ if (widthChanged) {
39
+ lastWidth = currentWidth;
40
+ }
41
+
42
+ return widthChanged;
39
43
  }
40
44
 
41
- return widthChanged
42
- }
45
+ return false;
46
+ };