Jump to content
Search Community

ligr

Business
  • Posts

    5
  • Joined

  • Last visited

Posts posted by ligr

  1. On 12/16/2020 at 5:25 AM, OSUblake said:

     

    GSAP will be global during development, so that could be why. Once you do a production build, the globals go away due to tree shaking. It's working as designed, which might cause problems for module users, but not everyone uses modules.

     


    Is there any recommended workaround to this for module users?

  2. Thanks!
     

    That hidden helper seems to have done the trick.

    Am I wrong in thinking the below modifications also mean you get the benefits of lag smoothing when the page is visible?
     

    function tickGSAPWhileHidden(value) {
      if (value === false) {
          document.removeEventListener("visibilitychange", tickGSAPWhileHidden.fn);
          return clearInterval(tickGSAPWhileHidden.id);
      }
      const onChange = () => {
          clearInterval(tickGSAPWhileHidden.id);
          document.hidden && (tickGSAPWhileHidden.id = setInterval(() => {
            gsap.ticker.lagSmoothing(0)
            gsap.ticker.tick()
          }, 100));
    
          !document.hidden && gsap.ticker.lagSmoothing(400, 40)
    
      };
      document.addEventListener("visibilitychange", onChange);
      tickGSAPWhileHidden.fn = onChange;
      onChange(); // in case the document is currently hidden.
    }

     

  3. I implemented this suggestion here in version 2 .

    Quote


    A fancy solution would be to write your own script so that while the tab is active, you have lagSmoothing() enabled and the ticker uses requestAnimationFrame, but then when the user switches tabs, you turn off lagSmoothing()

     

     

    This seems to not working using gsap.ticker.lastSmoothing(0) or // or false or 0 ,0. 

    Is this not supported in version 3?

×
×
  • Create New...