Jump to content
Search Community

Vadyaqq

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by Vadyaqq

  1. @Rodrigo  thank you for the previous answer, I took something for myself. But unfortunately I can't solve my problem. My task is to replace

                  element.addEventListener("click", () => {
        
                    if (element !== activeElement) {
                      activeElement.animation.reverse();
       
                      element.animation.play();
                      activeElement = element;
     
                    }
                  });

    with

     @click="handleIsActive

     in my methods . I apologize for not sending an example code right away, here it is -
    https://stackblitz.com/edit/vue-cmtt9a?file=src%2FApp.vue 

    Thank you for your time!

  2. Hi, I am new to gsap and my problem is to replace addEventListener with @click event  
      data() {
        return {
            elements: [],
            activeElement: null,
        };
      },
      methods: {

        categoryAnimationIsActive() {

            this.elements = gsap.utils.toArray(".category__item");
            this.activeElement = this.elements[0]; 

            gsap.set(this.elements, {
                y: 30
            });

            this.elements.forEach((el) => { 
                el.animation = gsap.to(el,{
                     y: 0,
                     paused: true
                 });
                if (el === this.activeElement) {
                    el.animation.progress(1);
                }

                  el.addEventListener("click", () => {
        
                    if (el !== this.activeElement) {
                      this.activeElement.animation.reverse();
       
                      el.animation.play();
                      this.activeElement = el;

                    }
                  });
            });   
        }

      },
      mounted() {
        this.categoryAnimationIsActive();
      }

×
×
  • Create New...