Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
Lag on GSAP animation for mobile browsers

I'm playing around with some simple GSAP animations and I'm noticing that there is an issue with them running smoothly on a mobile browser(Brave and Chrome Android). For example the following code looks perfect on desktop devices while on mobile the animations seem to lag.

   <div class="container" id="contentContainer">
      <div class="content-start">
          <div class="medium-box box-1">
              The Mekong river originates in the Himalayas in China, where it is known as the Lancang. It flows through the Lower Mekong Basin countries of Myanmar, Laos, Thailand, Cambodia and Vietnam, where it reaches the South China Sea.
          </div>
      </div>
   </div>

 let mySplitText = new SplitText('.box-1', { type: "words,chars" }),
    chars = mySplitText.chars; //an array of all the divs that wrap each character

    gsap.fromTo('.box-1',{y: '100%', opacity: 0},{y: 0, opacity: 1, duration: 1, scrollTrigger: {
      trigger: '.box-1',
      start: 'top 60%',
      end: "bottom 50%",
      pin: true,
      pinSpacing: false,
      markers: true,
      onEnter: () => {
        gsap.to('.box-1',{duration: 1, y: '0', opacity: 1})
        gsap.from(chars, {duration: 0.5,opacity: 1,scale: 0,ease: "back",stagger: 0.01})
      },
      onLeave: () => {
        gsap.to('.box-1',{duration: 1, y: '-100%', opacity: 0})
      },
      onEnterBack: () => {
        gsap.to('.box-1',{duration: 1, y: 0, opacity: 1})
        gsap.from(chars, {duration: 0.5, opacity: 1,scale: 0,ease: "back",stagger: 0.01})
      },
      onLeaveBack: () => {
        gsap.to('.box-1',{duration: 1, y: '100%', opacity: 0})
      }
    }})

I think one of the reasons the animation lags is because of the navigation bar on mobile devices that pops up when scrolling down, resizing the viewport, and changing the start and end triggers.

I also realize since I'm quite new that my code might not be very efficient and that might impact performance.

I would appreciate any tips as to how to make this scrolling experience smooth for all users on all devices.Thanks in advance.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda