Líneas de tiempo
Use tl para encadenar animaciones. El adaptador GSAP crea líneas de tiempo nativas, y el adaptador Motion crea secuencias de Motion. Los ejemplos siguientes usan GSAP; consulte la guía de Motion para conocer las opciones de suavizado y configuración de la línea de tiempo que admite.
Línea de tiempo básica
Añade tl para crear un contenedor de línea de tiempo:
<div data-animate="tl defaults:ease-elastic|duration-1">
<div data-animate="to:rotate-360"></div>
<div data-animate="to:rotate-360"></div>
</div>
Por diseño, Glaze incorpora en el ámbito de la línea de tiempo todos los elementos secundarios de un elemento declarado como línea de tiempo; no hace falta incluirlos explícitamente.
Valores predeterminados de la línea de tiempo
Establece valores predeterminados para toda la línea de tiempo:
<div data-animate="tl defaults:ease-elastic|duration-4 repeat-1 yoyo-true">
...
</div>
En un elemento de línea de tiempo, la cadena que sigue a tl establece las opciones de la propia línea de tiempo GSAP. Un segmento simple key-value establece una opción de nivel superior (repeat-1, yoyo-true), y key: seguido de valores separados por barras verticales establece una opción anidada: defaults:ease-elastic|duration-4 se convierte en defaults: { ease: "elastic", duration: 4 } y scrollTrigger:trigger-[&] se convierte en scrollTrigger: { trigger: element }. La notación de puntos, como scrollTrigger.trigger-[&], solo funciona dentro de las propiedades from: o to: de un elemento.
Control del tiempo
Ajusta el inicio de las animaciones secundarias con tl::
<div data-animate="tl defaults:ease-elastic|duration-4">
<div data-animate="to:rotate-360"></div>
<div data-animate="tl:[-=3] to:rotate-360"></div>
</div>
<div
class="grid gap-8"
data-animate="tl defaults:ease-elastic|duration-4 scrollTrigger:trigger-[&]"
>
<div
class="h-20 w-20 rounded-xl bg-amber-500"
data-animate="to:rotate-360"
></div>
<div
class="h-20 w-20 rounded-xl bg-green-500"
data-animate="tl:[-=3] to:rotate-360"
></div>
</div>
tl:[-=3] significa «empezar 3 segundos antes de que termine la animación anterior» (solapamiento).
Valores de tiempo habituales:
tl:[+=1]- Empezar 1 segundo después de que termine el anteriortl:[-=1]- Empezar 1 segundo antes de que termine el anterior (solapamiento)tl:[<]- Empezar al mismo tiempo que el anterior
Líneas de tiempo adaptables
Combina puntos de ruptura con líneas de tiempo:
<div data-animate="tl defaults:ease-power2.inOut|duration-2">
<div data-animate="to:rotate-360 @lg:to:xPercent-[50]"></div>
<div data-animate="tl:[-=1] to:rotate-360 @lg:to:xPercent-[-50]"></div>
</div>
<div
class="grid gap-8"
data-animate="tl defaults:ease-power2.inOut|duration-2 scrollTrigger:trigger-[&]"
>
<div
class="h-20 w-20 rounded-xl bg-amber-500"
data-animate="to:rotate-360 @lg:to:xPercent-[100]"
></div>
<div
class="h-20 w-20 rounded-xl bg-green-500"
data-animate="tl:[-=1] to:rotate-360 @lg:to:xPercent-[-100]"
></div>
</div>
La rotación siempre se produce, pero el movimiento horizontal solo se activa en pantallas grandes.
Líneas de tiempo con nombre
Asigna un nombre a tu línea de tiempo para poder hacer referencia a ella desde cualquier lugar:
<div data-animate="tl/main defaults:ease-power2.inOut|duration-2">
<div data-animate="to:rotate-360"></div>
</div>
<!-- Somewhere else in the DOM -->
<div data-animate="tl:main-[-=1] to:scale-1.5">...</div>
<div class="grid w-full grid-cols-2 justify-items-center">
<div
class="grid gap-8"
data-animate="tl/main defaults:ease-power2.inOut|duration-2 scrollTrigger:trigger-[&]"
>
<div
class="h-20 w-20 rounded-xl bg-amber-500"
data-animate="to:rotate-360"
></div>
<div
class="h-20 w-20 rounded-xl bg-green-500"
data-animate="tl:[-=1] to:rotate-360"
></div>
</div>
<div
class="tl grid gap-8"
data-animate="tl:main-[-=1] [&>div]:to:rotate-360|stagger-0.25"
>
<div class="h-20 w-20 rounded-xl bg-rose-500"></div>
<div class="h-20 w-20 rounded-xl bg-red-500"></div>
</div>
</div>
Usa tl/name para crear una línea de tiempo con nombre y tl:name para unirte a ella.