Skip to content

Commit 548b69c

Browse files
jeryjjeryjajlende
authored andcommitted
Fix scaling animation for device previews (#66132)
Co-authored-by: jeryj <[email protected]> Co-authored-by: ajlende <[email protected]>
1 parent 79f79e6 commit 548b69c

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

packages/base-styles/_animations.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@
4141
@warn "The `edit-post__fade-in-animation` mixin is deprecated. Use `animation__fade-in` instead.";
4242
@include animation__fade-in($speed, $delay);
4343
}
44+
45+
@mixin editor-canvas-resize-animation($additional-transition-rules...) {
46+
transition: all 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96), $additional-transition-rules;
47+
@include reduce-motion("transition");
48+
}

packages/block-editor/src/components/block-canvas/style.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ iframe[name="editor-canvas"] {
44
height: 100%;
55
display: block;
66
background-color: transparent;
7+
// Handles transitions between device previews
8+
@include editor-canvas-resize-animation;
79
}

packages/block-editor/src/components/iframe/content.scss

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@
55

66
.block-editor-iframe__html {
77
transform-origin: top center;
8-
// 400ms should match the animation speed used in iframe/index.js
9-
$zoomOutAnimation: all 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96);
10-
118
// We don't want to animate the transform of the translateX because it is used
129
// to "center" the canvas. Leaving it on causes the canvas to slide around in
1310
// odd ways.
14-
transition: $zoomOutAnimation, transform 0s scale 0s;
15-
@include reduce-motion("transition");
11+
@include editor-canvas-resize-animation(transform 0s, scale 0s, padding 0s);
1612

1713
&.zoom-out-animation {
1814
// we only want to animate the scaling when entering zoom out. When sidebars
1915
// are toggled, the resizing of the iframe handles scaling the canvas as well,
2016
// and the doubled animations cause very odd animations.
21-
transition: $zoomOutAnimation, transform 0s;
17+
@include editor-canvas-resize-animation(transform 0s);
2218
}
2319
}
2420

@@ -30,7 +26,7 @@
3026
$outer-container-width: var(--wp-block-editor-iframe-zoom-out-outer-container-width);
3127
$container-width: var(--wp-block-editor-iframe-zoom-out-container-width, 100vw);
3228
// Apply an X translation to center the scaled content within the available space.
33-
transform: translateX(calc(( #{$outer-container-width} - #{ $container-width }) / 2 / #{$scale}));
29+
transform: translateX(calc((#{$outer-container-width} - #{$container-width}) / 2 / #{$scale}));
3430
scale: #{$scale};
3531
background-color: $gray-300;
3632

0 commit comments

Comments
 (0)