Skip to content

Commit

Permalink
Add check to ensure that window.navigation.activation.from is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixarntz committed Jan 15, 2025
1 parent e334028 commit d8b9815
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wp-content/themes/twentyfifteen/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,15 @@ function twentyfifteen_scripts() {
'twentyfifteen-view-transitions',
get_template_directory_uri() . '/css/view-transitions.css',
array(),
'20241219'
'20250115'
);

// This script must be loaded prior to rendering, i.e. not in the footer and not deferred or async.
wp_enqueue_script(
'twentyfifteen-view-transitions',
get_template_directory_uri() . '/js/view-transitions.js',
array(),
'20241219'
'20250115'
);
}
add_action( 'wp_enqueue_scripts', 'twentyfifteen_scripts' );
Expand Down
4 changes: 4 additions & 0 deletions src/wp-content/themes/twentyfifteen/js/view-transitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ if ( !! window.navigation && 'CSSViewTransitionRule' in window ) {
} );

window.addEventListener( 'pagereveal', ( e ) => {
if ( ! window.navigation.activation.from ) {
return;
}

if ( e.viewTransition ) {
const transitionType = determineTransitionType( window.navigation.activation.from, window.navigation.activation.entry );

Expand Down

0 comments on commit d8b9815

Please sign in to comment.