Skip to content

Commit

Permalink
Use iframeDocument.document.containerHeight to get the latest value i…
Browse files Browse the repository at this point in the history
…f container height has changed between renders
  • Loading branch information
jeryj committed Dec 2, 2024
1 parent 6b324b5 commit 39a27cd
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,10 @@ export function useScaleCanvas( {
// appenders may appear or disappear, so we need to get the height from
// the iframe at this point when we're about to animate the zoom out.
// The iframe scrollTop, scrollHeight, and clientHeight will all be
// the most accurate. clientHeight has a performance hit though, so we
// rely on containerHeight from the resize listener.
// the most accurate.
transitionFromRef.current.containerHeight =
transitionFromRef.current.containerHeight ??
containerHeight;
containerHeight; // Use containerHeight, as it's the previous container height value if none was set.
transitionFromRef.current.scrollTop =
iframeDocument.documentElement.scrollTop;
transitionFromRef.current.scrollHeight =
Expand All @@ -419,7 +418,8 @@ export function useScaleCanvas( {
transitionToRef.current = {
scaleValue,
frameSize,
containerHeight,
containerHeight:
iframeDocument.documentElement.clientHeight, // use clientHeight to get the actual height of the new container, as it will be the most up-to-date.
};
transitionToRef.current.scrollTop = computeScrollTopNext(
transitionFromRef.current,
Expand Down

0 comments on commit 39a27cd

Please sign in to comment.