Skip to content

Commit

Permalink
fix: animation happens when visibility state is toggled
Browse files Browse the repository at this point in the history
  • Loading branch information
cristinecula authored and JockeCK committed Oct 14, 2021
1 parent 2598f9f commit db61b0d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/use-track-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ 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 -
20 /* scrollbar width */ -
44 /* checkbox width */ -
24 /* expand button width */
)
),
);
},
observer = new ResizeObserver(onResize);

observer.observe(host);
Expand Down

0 comments on commit db61b0d

Please sign in to comment.