Jump to content
Search Community

Thomas Miller

Premium
  • Posts

    9
  • Joined

  • Last visited

Posts posted by Thomas Miller

  1. I'm trying to setup a simple fade-in animation on scroll using the new (💥 awesome 💥) Scrolltrigger plugin.

     

    I want the scrolltrigger to add an "active" class on the element, only once, the first time the element enters the viewport. That way I just use css to fade-in the element.

     

    I've tried using the "once" parameter, but that removes the class completely when the Scrolltrigger is no longer active.

     

    Any help would be appreciated 🙏

    See the Pen zYrqaRL by Meuss (@Meuss) on CodePen

    • Thanks 1
  2. Hey!


    I'm trying to delete a TimelineMax, once the user changes pages. I'm actually using Vue, so basically when a component gets destroyed, I want to totally remove the animations in that component.

     

    However, I'm having a hard time completely removing it. It never actually gets destroyed, I'm doing something wrong.

     

    Here is the pseudo-code I'm using (without the Vue stuff..):

     

    // when omponent created, execute animation
    animate(true);
    // when component destroyed
    animate(false);
    
    function animate(x) {
      let tl = new TimelineMax({ repeat: -1 });
      // elements that I will animate
      const item1 = document.querySelector('.item1');
      const item2 = document.querySelector('.item2');
      const item3 = document.querySelector('.item3');
    
      // sub-timeline
      function anim(element) {
        const item = element;
        const subtimeline = new TimelineMax();
        // do the animations for one element
        subtimeline.add(() => { console.log('animating'); }, '+=0');
        subtimeline.to(item, 3, { x: '20', ease: Power4.easeInOut }, '+=0');
        // lots of animations..
        return subtimeline;
      }
      if (!x) {
        // I've tried lots of variants,
        // none of these work
        // I see the 'destroy' in the console when component is removed, but I still see the 'animating' as well, indefinitely..
        console.log('destroy');
        tl.invalidate();
        tl.invalidate().pause();
        tl.kill();
        tl = null;
      } else {
        tl.add(anim(item1), 0);
        tl.add(anim(item2), '+=1');
        tl.add(anim(item3), '+=1');
      }
    }

     

  3. Been on this for hours ? I've recently purchased the club greensock license, and I'm trying to use some premium plugins in my project, unsuccessfully.

    I'm using the plugins with the vue cli webpack template... Has anyone been able to get this working? If so, could you please share some of your setup? I've been going through multiple forum posts involving module bundler bugs. I've tried out so many suggestions, nothing ever works.

     

    I am not super familiar with customizing webpack, normally I simply import different modules and everything works. Not the case with the greensock plugins unfortunately. I've tried loading them in different ways (/src/assets or copying them directly in node_modules/gsap), but nothing seems to work for me ?

     

    I always get errors, depending on what hack I'm doing (based on previous forum posts), most of the time one of these:
     

    Cannot read property '_gsDefine' of undefined
    
    Module not found: Error: Can't resolve '../TweenLite.min.js' in ....
    
    document not defined...

     

    Since vue is getting pretty popular, and I'm guessing lots of people are using the vue-cli webpack template, I was hoping that someone could post here how they got the club greensock plugins to work?

×
×
  • Create New...