diff --git a/lib/use-track-size.js b/lib/use-track-size.js index ec60f3e2..ab524893 100644 --- a/lib/use-track-size.js +++ b/lib/use-track-size.js @@ -2,7 +2,11 @@ import { useEffect } from 'haunted'; export const useTrackSize = (host, setCanvasWidth) => useEffect(() => { - const onResize = ([entry]) => + const onResize = ([entry]) => { + if (entry.contentRect?.width === 0) { + return; + } + requestAnimationFrame(() => setCanvasWidth( entry.contentRect?.width - @@ -10,7 +14,8 @@ export const useTrackSize = (host, setCanvasWidth) => 44 /* checkbox width */ - 24 /* expand button width */ ) - ), + ); + }, observer = new ResizeObserver(onResize); observer.observe(host);