Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

336
Vistas
How to play a CSS animation on every page transition with Next.js?

I'm using Next.js to generate a static website. I have created a CSS animation that plays in full screen when a specific div is created. I put the div in my _app.tsx, so that during most of the page transitions the animation can be played, because many of the HTML elements, including the div, gets destroyed and created during these transitions. However, it won't play when you move from a page to one with almost the same HTML structure (such as blog articles), probably because the div doesn't get destroyed and recreated. Is there a way to play a CSS animation on every page transition? For example, can I detect page transition and remove/regenerate the div when it won't be removed/regenerated?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I figured it out by myself after thinking about it for a while.

.animation[animate="0"] {
    animation: none;
}
.animation[animate="1"] {
    animation: /* ... */;
}

then

import Router from "next/router"
export const Animations = () => {
    const [i,setI] = useState(1)
    Router.events.on('routeChangeComplete', () => setI(1))
    Router.events.on('routeChangeStart', () => setI(0))
    return (
        <div className="animation" animate={i}></div>
    )
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda