CodeByZach/pace

Javascript doesn't always get executed

Stelikas opened this issue · 0 comments

I recently started using Turbolinks with pace.js to handle the initial page load and i'm facing a weird issue where sometimes Javascript doesn't get executed with no errors.

Pace.once('done', () => {
  
      var tl = gsap.timeline();

        tl.set('html, body', {
            overflowY: 'unset'
        })
        .set('#app', {
            visibility: 'visible', 
        })
        .add('do')
        .to('.turbo__lines', {
            stagger: .3,
            height: '0%'
        })
        .to('.turbo__logo, .__loader', {
            duration: .3, 
            opacity: 0
        }, 'do')
        .to('.turbo__loader', {
            visibility: 'hidden'
        }).pause();

          tl.play(); //<---Sometimes it doesn't fire
          console.log(tl) //<----Always fires
        
})

I honestly can't find a reason on why this is happening, i get no errors.