Timelines
Use tl para encadear animações. O adaptador GSAP cria linhas do tempo nativas, e o adaptador Motion cria sequências do Motion. Os exemplos abaixo usam GSAP; consulte o guia do Motion para conhecer as configurações de suavização e de linha do tempo compatíveis.
Timeline básica
Adicione tl para criar um contêiner de timeline:
<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 padrão, Glaze incorpora todos os elementos filhos de um elemento declarado como timeline ao escopo dela; não é necessário incluí-los explicitamente.
Valores padrão da timeline
Defina valores padrão para toda a timeline:
<div data-animate="tl defaults:ease-elastic|duration-4 repeat-1 yoyo-true">
...
</div>
Em um elemento de timeline, a string após tl define as opções da própria timeline GSAP. Um segmento simples key-value define uma opção de nível superior (repeat-1, yoyo-true), e key: seguido de valores separados por barras verticais define uma opção aninhada: defaults:ease-elastic|duration-4 se torna defaults: { ease: "elastic", duration: 4 }, e scrollTrigger:trigger-[&] se torna scrollTrigger: { trigger: element }. A notação de ponto, como scrollTrigger.trigger-[&], só funciona nas propriedades from: ou to: de um elemento.
Controle de tempo
Ajuste o início das animações filhas usando 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 "começar 3 segundos antes do fim da animação anterior" (sobreposição).
Valores de temporização comuns:
tl:[+=1]- Iniciar 1 segundo após o término do anteriortl:[-=1]- Iniciar 1 segundo antes do término do anterior (sobreposição)tl:[<]- Iniciar ao mesmo tempo que o anterior
Timelines responsivas
Combine breakpoints com timelines:
<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>
A rotação sempre acontece, mas o movimento horizontal só começa em telas grandes.
Timelines nomeadas
Dê um nome à sua timeline para referenciá-la de qualquer 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>
Use tl/name para criar uma timeline nomeada e tl:name para se conectar a ela.