Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to disable animation from specific element on the page #34

Open
AnatoliiCubex opened this issue Sep 19, 2024 · 0 comments

Comments

@AnatoliiCubex
Copy link

AnatoliiCubex commented Sep 19, 2024

Hi! Thank you for this library—it has significantly improved transitions and saved me a lot of time. However, is it possible to specify which content might be static?

I have a sidebar on the left with three links, and all three pages contain an h1 tag with the page name and some content(by the way this is the vercel tutorial called Acme). I've added a "disabled" transition name to the sidebar div wrapper, so it no longer animates (which is fine). However, when I try to remove the animation from the h1 tag by adding style={{viewTransitionName: "disabled"}}, the animation gets disabled on whole page when transitioning from this page to another and still works when navigating to this page. Even though it only suppose to remove animation from h1

Is it possible to disable animation for specific elements on the page?

My layout (app/dashboard/layout.tsx):

export default function DashboardLayout({ children }: PropsWithChildren) {
  return (
    <div className='flex md:flex-row flex-col h-screen md:overflow-hidden'>
      <SideNav />
      <div className='flex-grow p-6 md:p-12 md:overflow-y-auto'>{children}</div>
    </div>
  );
}

Here’s the code for the sidebar (app/components/sidebar):

export default function SideNav() {
  return (
    <div style={{ viewTransitionName: "disabled" }}>
      {/* sidebar content */}
    </div>
  );
}

Example of the page (app/dashboard/(overview)/page.tsx):

export default async function Page() {
  return (
    <main>
      <h1
        style={{ viewTransitionName: "disabled" }}
        className={`${lusitana.className} mb-4 text-xl md:text-2xl`}
      >
        Dashboard
      </h1>
      {/* rest of the page content */}
    </main>
  );
}
@AnatoliiCubex AnatoliiCubex changed the title Is it possible to define which exact elements to have animation Is it possible to disable animation from specific element on the page Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant