@heliosgraphics/ui 2.0.1-alpha.6 → 2.0.1-alpha.7

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.
@@ -6,9 +6,17 @@ export const useIntersection = (ref: RefObject<HTMLElement>): boolean => {
6
6
  const [isIntersecting, setIntersecting] = useState<boolean>(false)
7
7
 
8
8
  useEffect(() => {
9
- if (!ref?.current) return
9
+ if (!ref?.current) {
10
+ setIntersecting(false)
11
+ return
12
+ }
10
13
 
11
- const observer = new IntersectionObserver(([entry]) => setIntersecting(!!entry?.isIntersecting))
14
+ if (typeof globalThis.IntersectionObserver !== "function") {
15
+ setIntersecting(false)
16
+ return
17
+ }
18
+
19
+ const observer = new globalThis.IntersectionObserver(([entry]) => setIntersecting(!!entry?.isIntersecting))
12
20
 
13
21
  observer.observe(ref.current)
14
22
 
@@ -18,7 +18,14 @@ export const useResizeObserver = (): readonly [(element: HTMLDivElement | null)
18
18
  }
19
19
 
20
20
  if (element) {
21
- resizeObserverRef.current = new ResizeObserver((entries) => {
21
+ const rect = element.getBoundingClientRect()
22
+ setWidth(rect.width)
23
+
24
+ if (typeof globalThis.ResizeObserver !== "function") {
25
+ return
26
+ }
27
+
28
+ resizeObserverRef.current = new globalThis.ResizeObserver((entries) => {
22
29
  if (entries[0]) {
23
30
  const entryWidth = entries[0].contentRect.width
24
31
  setWidth(entryWidth)
@@ -26,9 +33,6 @@ export const useResizeObserver = (): readonly [(element: HTMLDivElement | null)
26
33
  })
27
34
 
28
35
  resizeObserverRef.current.observe(element)
29
-
30
- const rect = element.getBoundingClientRect()
31
- setWidth(rect.width)
32
36
  } else {
33
37
  setWidth(0)
34
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heliosgraphics/ui",
3
- "version": "2.0.1-alpha.6",
3
+ "version": "2.0.1-alpha.7",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "*.css",