Skip to content

Commit 6f33080

Browse files
author
Felix Arntz
committed
Use CSS registered custom property for animation angle (props @westonruter).
1 parent 6c1a23b commit 6f33080

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/wp-includes/css/view-transitions-animation-wipe.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
@property --wp-view-transition-angle {
2+
syntax: "<angle>";
3+
initial-value: 270deg;
4+
inherits: false;
5+
}
6+
17
@property --wp-view-transition-progress {
28
syntax: "<number>";
39
initial-value: 0;
@@ -32,5 +38,5 @@
3238
transform: none;
3339
animation: wp-view-transition-new-animation 1.2s cubic-bezier(0.45, 0, 0.35, 1.0);
3440
animation-fill-mode: both;
35-
mask-image: linear-gradient(270deg, #000 calc(-70% + calc(170% * var(--wp-view-transition-progress, 0))), transparent calc(170% * var(--wp-view-transition-progress, 0)));
41+
mask-image: linear-gradient(var(--wp-view-transition-angle), #000 calc(-70% + calc(170% * var(--wp-view-transition-progress, 0))), transparent calc(170% * var(--wp-view-transition-progress, 0)));
3642
}

src/wp-includes/theme.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4485,12 +4485,18 @@ function wp_load_view_transitions() {
44854485
case 'wipe-from-bottom':
44864486
$animation_stylesheet = file_get_contents( ABSPATH . WPINC . "/css/view-transitions-animation-wipe{$suffix}.css" );
44874487
if ( str_ends_with( $theme_support['default-animation'], 'left' ) ) {
4488-
$animation_stylesheet = str_replace( '270deg', '90deg', $animation_stylesheet );
4488+
$animation_angle = 90;
44894489
} elseif ( str_ends_with( $theme_support['default-animation'], 'top' ) ) {
4490-
$animation_stylesheet = str_replace( '270deg', '180deg', $animation_stylesheet );
4490+
$animation_angle = 180;
44914491
} elseif ( str_ends_with( $theme_support['default-animation'], 'bottom' ) ) {
4492-
$animation_stylesheet = str_replace( '270deg', '0deg', $animation_stylesheet );
4492+
$animation_angle = 0;
4493+
} else {
4494+
$animation_angle = 270;
44934495
}
4496+
$animation_stylesheet .= sprintf(
4497+
'::view-transition-new(root) { --wp-view-transition-angle: %ddeg; }',
4498+
$animation_angle
4499+
);
44944500
wp_add_inline_style( 'wp-view-transitions', $animation_stylesheet );
44954501
break;
44964502
case 'default':

0 commit comments

Comments
 (0)