Jump to content
Search Community

flim

Members
  • Posts

    28
  • Joined

  • Last visited

Posts posted by flim

  1. I want to reset the animation to the beginning of the animation when switching from desktop to mobile screen, not revert playback.

    Now I just check mediaquery to reload the page without animation when switching to mobile, or set animation when change to the desktop view. 

  2. 3 hours ago, OSUblake said:

    Hi flim, 

     

    Check out the new .isInViewport() method.

    https://greensock.com/docs/v3/Plugins/ScrollTrigger/static.isInViewport()

     

    So if it's in the viewport, just set the animation's progress to 1.

    if (ScrollTrigger.isInViewport(myElement)) {
      myAnimation.progress(1);
    }

     

    Hi OSUblake,

     

    Thanks for the advice, I shall read the doc more carefully. Here is my trial, if I change the zoom to 0.25x, the element 'b' will be at the end position, change the zoom to 1x the normal scroll animation resume.

     

    See the Pen NWvewXE by fredericklim (@fredericklim) on CodePen

     

    It is not perfect, the animation position will jump to the end if I resize the viewport which is large enough to make the element in the viewport. Any advice?

     

  3. I want the element to show in the animation "end" position when it is already on the screen, i.e. after page loaded.

    For instance, in the codepen, change the zoom to "0.25x", "b" will be visible, "b" will start to play just if I run the codepen again. How to make "b" start in the animation end position if it is visible already? Like when "b" is visible after page loaded, the tween duration is "0".

    See the Pen abyRXVb by fredericklim (@fredericklim) on CodePen

  4. Thanks for the docs link. But I not quit understand why need to include window, because if I remove window then the code will not work. In other examples there is no window before gsap.registerPlugin.

     

    const registerPlugin = gsap.registerPlugin;

     

    Also I cannot get the meaning of "..." in the line "...document.querySelectorAll(".apple-image--complete")"

    const COMPLETES = [
      ...document.querySelectorAll(".apple-image--complete"),
      document.querySelector(".apple-image--complete"),
    ];
     
×
×
  • Create New...