-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zoom out: fix scaling issues #65998
Zoom out: fix scaling issues #65998
Conversation
Size Change: -22 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
Flaky tests detected in 47b31ed. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11276671576
|
Some related conversations here #65188 (comment) |
12eee91
to
b530665
Compare
Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size.
This reverts commit 38de9fc.
b530665
to
7af85bd
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves the reflow. Nice.
Okay, that’s no fault of this PR, that’s consequence of #66018 |
There was a conflict while trying to cherry-pick the commit to the wp/6.7 branch. Please resolve the conflict manually and create a PR to the wp/6.7 branch. PRs to wp/6.7 are similar to PRs to trunk, but you should base your PR on the wp/6.7 branch instead of trunk.
|
* changed from using borders to use pseudo elements * added comments * Include frame size in the scaling calculation Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size. * Account for scaling in the frame height * Calculation in CSS * Revert "Calculation in CSS" This reverts commit 38de9fc. * Add comment about why the calculation for scaling needs to happen in the JS * Force px value for frameSize * Restore previous frameSize var setting * Add back line break * Use padding top/bottom instead of before/after for top/bottom frame * Remove more before/after css since we are using padding --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: Alex Lende <alex+github.com@lende.xyz> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org> # Conflicts: # packages/block-editor/src/components/iframe/style.scss
Trying a manual backport in #66047. Reviews appreciated. |
* changed from using borders to use pseudo elements * added comments * Include frame size in the scaling calculation Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size. * Account for scaling in the frame height * Calculation in CSS * Revert "Calculation in CSS" This reverts commit 38de9fc. * Add comment about why the calculation for scaling needs to happen in the JS * Force px value for frameSize * Restore previous frameSize var setting * Add back line break * Use padding top/bottom instead of before/after for top/bottom frame * Remove more before/after css since we are using padding --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: Alex Lende <alex+github.com@lende.xyz> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org> # Conflicts: # packages/block-editor/src/components/iframe/style.scss
* changed from using borders to use pseudo elements * added comments * Include frame size in the scaling calculation Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size. * Account for scaling in the frame height * Calculation in CSS * Revert "Calculation in CSS" This reverts commit 38de9fc. * Add comment about why the calculation for scaling needs to happen in the JS * Force px value for frameSize * Restore previous frameSize var setting * Add back line break * Use padding top/bottom instead of before/after for top/bottom frame * Remove more before/after css since we are using padding --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: Alex Lende <alex+github.com@lende.xyz> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org> # Conflicts: # packages/block-editor/src/components/iframe/style.scss
* changed from using borders to use pseudo elements * added comments * Include frame size in the scaling calculation Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size. * Account for scaling in the frame height * Calculation in CSS * Revert "Calculation in CSS" This reverts commit 38de9fc. * Add comment about why the calculation for scaling needs to happen in the JS * Force px value for frameSize * Restore previous frameSize var setting * Add back line break * Use padding top/bottom instead of before/after for top/bottom frame * Remove more before/after css since we are using padding --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: Alex Lende <alex+github.com@lende.xyz> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
* changed from using borders to use pseudo elements * added comments * Include frame size in the scaling calculation Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size. * Account for scaling in the frame height * Calculation in CSS * Revert "Calculation in CSS" This reverts commit 38de9fc. * Add comment about why the calculation for scaling needs to happen in the JS * Force px value for frameSize * Restore previous frameSize var setting * Add back line break * Use padding top/bottom instead of before/after for top/bottom frame * Remove more before/after css since we are using padding --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: Alex Lende <alex+github.com@lende.xyz> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
* changed from using borders to use pseudo elements * added comments * Include frame size in the scaling calculation Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size. * Account for scaling in the frame height * Calculation in CSS * Revert "Calculation in CSS" This reverts commit 38de9fc. * Add comment about why the calculation for scaling needs to happen in the JS * Force px value for frameSize * Restore previous frameSize var setting * Add back line break * Use padding top/bottom instead of before/after for top/bottom frame * Remove more before/after css since we are using padding --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: Alex Lende <alex+github.com@lende.xyz> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
* changed from using borders to use pseudo elements * added comments * Include frame size in the scaling calculation Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size. * Account for scaling in the frame height * Calculation in CSS * Revert "Calculation in CSS" This reverts commit 38de9fc. * Add comment about why the calculation for scaling needs to happen in the JS * Force px value for frameSize * Restore previous frameSize var setting * Add back line break * Use padding top/bottom instead of before/after for top/bottom frame * Remove more before/after css since we are using padding --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: Alex Lende <alex+github.com@lende.xyz> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
* changed from using borders to use pseudo elements * added comments * Include frame size in the scaling calculation Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size. * Account for scaling in the frame height * Calculation in CSS * Revert "Calculation in CSS" This reverts commit 38de9fc. * Add comment about why the calculation for scaling needs to happen in the JS * Force px value for frameSize * Restore previous frameSize var setting * Add back line break * Use padding top/bottom instead of before/after for top/bottom frame * Remove more before/after css since we are using padding --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: Alex Lende <alex+github.com@lende.xyz> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
This reverts commit 12a7294.
* changed from using borders to use pseudo elements * added comments * Include frame size in the scaling calculation Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size. * Account for scaling in the frame height * Calculation in CSS * Revert "Calculation in CSS" This reverts commit 38de9fc. * Add comment about why the calculation for scaling needs to happen in the JS * Force px value for frameSize * Restore previous frameSize var setting * Add back line break * Use padding top/bottom instead of before/after for top/bottom frame * Remove more before/after css since we are using padding --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: Alex Lende <alex+github.com@lende.xyz> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
* changed from using borders to use pseudo elements * added comments * Include frame size in the scaling calculation Instead of adding the frame size as a border (which causes reflow issues), include the frame size in the scaling calculation so there's always a left/right gutter of the frame size. * Account for scaling in the frame height * Calculation in CSS * Revert "Calculation in CSS" This reverts commit 38de9fc. * Add comment about why the calculation for scaling needs to happen in the JS * Force px value for frameSize * Restore previous frameSize var setting * Add back line break * Use padding top/bottom instead of before/after for top/bottom frame * Remove more before/after css since we are using padding --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: Alex Lende <alex+github.com@lende.xyz> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
What?
Closes #65757.
As @stokesman discovered in #65814, we need to account for the frame size in the scaling in order to prevent reflows of the content. This PR takes that idea in a slightly different direction.
Why?
The trunk implementation uses a
border
applied to the iframe to offset it from the edges of the frame. Applying the border causes a reflow of content because the border is included in the width of the html element.Margin and padding both cause the same problem as they are on the inside of the iframe. And the
box-sizing
property also doesn't work because we're working within the iframe.We need the iframe to be full width of the canvas to be able to scroll anywhere in the zoomed out canvas area and avoid double scrollbars. Because of this, any offsetting needs to be done within the iframe.
The fix then, is to apply the frame size into the scaling calculation for the width. When we scale the canvas, we need to make sure it scales far enough that it also includes the frame size offset. This means we can remove the border (no reflowing) and preserve a frame offset.
How?
padding
as it seems to work across browsers (unlikemargin
) and makes more sense contextually (unlikeborder
or pseudo-elements).frameSize
in the calculation forscale
so that none of thepadding
/margin
/border
are included in the width calculation.Testing Instructions
Follow @stokesman's testing procedure from #65814.
Visually, this means that content will not reflow when zoom out is engaged.
Testing Instructions for Keyboard
Screenshots or screencast