Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Zoom out: Correctly scale canvas in non-iframe editor
  • Loading branch information
t-hamano committed Aug 26, 2025
commit 9e563f81ba0d701b600ac34274367ab122077be7
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,11 @@ export function useScaleCanvas( {
const trigger =
iframeDocument && previousIsZoomedOut.current !== isZoomedOut;

previousIsZoomedOut.current = isZoomedOut;

if ( ! trigger ) {
return;
}

previousIsZoomedOut.current = isZoomedOut;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing well for me. I think I'd prefer to keep the previous previousIsZoomedOut.current !== isZoomedOut alongside the setting of the ref though. I think it will be easier to understand why we don't want the animation to run when the iframeDocument is false. What do you think of this instead?

// If we don't have an iframe document, we don't run or track the animation.
if ( ! iframeDocument ) {
	return;
}

const triggerAnimation = isZoomedOut !== previousIsZoomedOut.current;
previousIsZoomedOut.current = isZoomedOut;

// Zoom state has not changed, so we don't need to run the animation.
if ( ! triggerAnimation ) {
	return;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 0dbaf38

The suggested logic seems to work correctly!

startAnimationRef.current = true;

if ( ! isZoomedOut ) {
Expand Down
Loading