-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add useScaleCanvas: Web Animations API for zoom in/out animation #66917
Changes from 62 commits
af08ecc
c83c99f
ec58902
6582cce
ce9497e
26d9e3a
3947ab0
cb47e82
bc8cca6
578c923
d2c16a6
0faf418
ab8038e
ba32f99
0b640ee
6a3f7a0
55df6fe
7ba67b2
2dc137f
3eabcf5
8b8c206
23bd453
8cbe2be
4c9543e
4e87729
17f50d5
b049f4b
61a0de9
ac52f2d
6b23a30
fd74dc4
bfaf7e4
cc28155
d407ee6
c8f2cc7
7903702
72f5785
53d8f6f
a25f7da
5fcd9c1
1c5d7d5
96d62ab
ec37f26
28cff48
28ded6a
1dbdc82
cf8ffde
f338821
5c93399
ff03e1e
65bd82e
f236641
83ee4c5
32b24e5
1407f8f
d5402bc
fc6b4ee
2325135
b41d282
0ff92b5
92e0e52
fb16c4f
4076a7b
798549e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
|
||
.block-editor-iframe__html { | ||
transform-origin: top center; | ||
// We don't want to animate the transform of the translateX because it is used | ||
// to "center" the canvas. Leaving it on causes the canvas to slide around in | ||
// odd ways. | ||
@include editor-canvas-resize-animation( transform 0s, scale 0s, padding 0s, translate 0s); | ||
// Prevents a flash of background color change when entering/exiting zoom out | ||
transition: background-color 400ms; | ||
|
||
&.zoom-out-animation { | ||
$scroll-top: var(--wp-block-editor-iframe-zoom-out-scroll-top, 0); | ||
|
@@ -18,53 +16,48 @@ | |
right: 0; | ||
top: calc(-1 * #{$scroll-top}); | ||
bottom: 0; | ||
translate: 0 calc(#{$scroll-top} - #{$scroll-top-next}); | ||
// Force preserving a scrollbar gutter as scrollbar-gutter isn't supported in all browsers yet, | ||
// and removing the scrollbar causes the content to shift. | ||
overflow-y: scroll; | ||
|
||
// We only want to animate the scaling when entering zoom out. When sidebars | ||
// are toggled, the resizing of the iframe handles scaling the canvas as well, | ||
// and the doubled animations cause very odd animations. | ||
@include editor-canvas-resize-animation( transform 0s, top 0s, bottom 0s, right 0s, left 0s ); | ||
} | ||
} | ||
|
||
.block-editor-iframe__html.is-zoomed-out { | ||
$scale: var(--wp-block-editor-iframe-zoom-out-scale); | ||
$frame-size: var(--wp-block-editor-iframe-zoom-out-frame-size); | ||
$inner-height: var(--wp-block-editor-iframe-zoom-out-inner-height); | ||
$content-height: var(--wp-block-editor-iframe-zoom-out-content-height); | ||
$scale-container-width: var(--wp-block-editor-iframe-zoom-out-scale-container-width); | ||
$container-width: var(--wp-block-editor-iframe-zoom-out-container-width, 100vw); | ||
// Apply an X translation to center the scaled content within the available space. | ||
transform: translateX(calc((#{$scale-container-width} - #{$container-width}) / 2 / #{$scale})); | ||
scale: #{$scale}; | ||
background-color: $gray-300; | ||
&.is-zoomed-out { | ||
$scale: var(--wp-block-editor-iframe-zoom-out-scale, 1); | ||
$frame-size: var(--wp-block-editor-iframe-zoom-out-frame-size, 0); | ||
$inner-height: var(--wp-block-editor-iframe-zoom-out-inner-height); | ||
$content-height: var(--wp-block-editor-iframe-zoom-out-content-height); | ||
$scale-container-width: var(--wp-block-editor-iframe-zoom-out-scale-container-width); | ||
$container-width: var(--wp-block-editor-iframe-zoom-out-container-width, 100vw); | ||
// Apply an X translation to center the scaled content within the available space. | ||
transform: translateX(calc((#{$scale-container-width} - #{$container-width}) / 2 / #{$scale})); | ||
scale: $scale; | ||
background-color: $gray-300; | ||
|
||
// Chrome seems to respect that transform scale shouldn't affect the layout size of the element, | ||
// so we need to adjust the height of the content to match the scale by using negative margins. | ||
$extra-content-height: calc(#{$content-height} * (1 - #{$scale})); | ||
$total-frame-height: calc(2 * #{$frame-size} / #{$scale}); | ||
$total-height: calc(#{$extra-content-height} + #{$total-frame-height} + 2px); | ||
margin-bottom: calc(-1 * #{$total-height}); | ||
// Add the top/bottom frame size. We use scaling to account for the left/right, as | ||
// the padding left/right causes the contents to reflow, which breaks the 1:1 scaling | ||
// of the content. | ||
padding-top: calc(#{$frame-size} / #{$scale}); | ||
padding-bottom: calc(#{$frame-size} / #{$scale}); | ||
// Chrome seems to respect that transform scale shouldn't affect the layout size of the element, | ||
// so we need to adjust the height of the content to match the scale by using negative margins. | ||
$extra-content-height: calc(#{$content-height} * (1 - #{$scale})); | ||
$total-frame-height: calc(2 * #{$frame-size} / #{$scale}); | ||
$total-height: calc(#{$extra-content-height} + #{$total-frame-height} + 2px); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is 2px? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the same 2px from before; the line just got moved. I'm not entirely sure what it does, but I assume it's a 1px border somewhere that isn't accounted for in the height. |
||
margin-bottom: calc(-1 * #{$total-height}); | ||
|
||
body { | ||
min-height: calc((#{$inner-height} - #{$total-frame-height}) / #{$scale}); | ||
// Add the top/bottom frame size. We use scaling to account for the left/right, as | ||
// the padding left/right causes the contents to reflow, which breaks the 1:1 scaling | ||
// of the content. | ||
padding-top: calc(#{$frame-size} / #{$scale}); | ||
padding-bottom: calc(#{$frame-size} / #{$scale}); | ||
|
||
> .is-root-container:not(.wp-block-post-content) { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
body { | ||
min-height: calc((#{$inner-height} - #{$total-frame-height}) / #{$scale}); | ||
|
||
> main { | ||
> .is-root-container:not(.wp-block-post-content) { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
|
||
> main { | ||
flex: 1; | ||
} | ||
} | ||
} | ||
} | ||
|
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.
Removed the mixin, as it's only used once.