Skip to content

Commit

Permalink
Avoid the types view transitions as it's not supported in all browser…
Browse files Browse the repository at this point in the history
…s that support view transitions
  • Loading branch information
youknowriad committed Jun 4, 2024
1 parent 01ce00e commit fa43174
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 2 additions & 4 deletions packages/edit-site/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@
}

/* stylelint-disable -- Disable reason: View Transitions not supported properly by stylelint. */
html:active-view-transition-type(canvas-mode-edit) {
&::view-transition-group(toggle) {
animation-delay: 255ms;
}
html.canvas-mode-edit-transition::view-transition-group(toggle) {
animation-delay: 255ms;
}
/* stylelint-enable */

Expand Down
15 changes: 10 additions & 5 deletions packages/edit-site/src/store/private-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ export const setCanvasMode =
if ( ! document.startViewTransition ) {
switchCanvasMode();
} else {
document.startViewTransition( {
update: () => {
switchCanvasMode();
},
types: [ 'canvas-mode-' + mode ],
document.documentElement.classList.add(
`canvas-mode-${ mode }-transition`
);
const transition = document.startViewTransition( () =>
switchCanvasMode()
);
transition.finished.finally( () => {
document.documentElement.classList.remove(
`canvas-mode-${ mode }-transition`
);
} );
}
};
Expand Down

0 comments on commit fa43174

Please sign in to comment.