Skip to content

Commit

Permalink
Animate on route change
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Apr 2, 2024
1 parent 7f00034 commit 8358622
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ export default function Layout() {
const isEditorLoading = useIsSiteEditorLoading();
const [ isResizableFrameOversized, setIsResizableFrameOversized ] =
useState( false );
const { areas, widths } = useLayoutAreas();
const { key: routeKey, areas, widths } = useLayoutAreas();
const animationRef = useMovingAnimation( {
triggerAnimationOnChange: canvasMode,
triggerAnimationOnChange: canvasMode + '__' + routeKey,
} );

// This determines which animation variant should apply to the header.
Expand Down
6 changes: 6 additions & 0 deletions packages/edit-site/src/components/layout/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function useLayoutAreas() {
if ( path === '/page' ) {
const isListLayout = layout === 'list' || ! layout;
return {
key: 'pages-list',
areas: {
content: <PagePages />,
preview: isListLayout && (
Expand Down Expand Up @@ -62,6 +63,7 @@ export default function useLayoutAreas() {
// Regular other post types
if ( postType && postId ) {
return {
key: 'page',
areas: {
preview: <Editor isLoading={ isSiteEditorLoading } />,
mobile:
Expand All @@ -76,6 +78,7 @@ export default function useLayoutAreas() {
if ( path === '/wp_template' ) {
const isListLayout = isCustom !== 'true' && layout === 'list';
return {
key: 'templates-list',
areas: {
content: (
<PageTemplatesTemplateParts
Expand All @@ -101,6 +104,7 @@ export default function useLayoutAreas() {
if ( path === '/wp_template_part/all' ) {
const isListLayout = isCustom !== 'true' && layout === 'list';
return {
key: 'template-parts',
areas: {
content: (
<PageTemplatesTemplateParts
Expand All @@ -125,6 +129,7 @@ export default function useLayoutAreas() {
// Patterns
if ( path === '/patterns' ) {
return {
key: 'patterns',
areas: {
content: <PagePatterns />,
mobile: <PagePatterns />,
Expand All @@ -134,6 +139,7 @@ export default function useLayoutAreas() {

// Fallback shows the home page preview
return {
key: 'default',
areas: {
preview: <Editor isLoading={ isSiteEditorLoading } />,
mobile:
Expand Down

0 comments on commit 8358622

Please sign in to comment.