How to use the gsap/TweenMax.to function in gsap

To help you get started, we’ve selected a few gsap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skaltenegger / customcursor / website / src / js / demo5.js View on Github external
};

    // show the first image
    document
      .querySelector('.image-wrapper__img[data-index="1"]')
      .classList.add("is-visible");

    const navItems = document.querySelectorAll(".nav__link");
    navItems.forEach(item => {
      item.addEventListener("mouseenter", handleMouseEnter);
      item.addEventListener("click", handleMouseClick);
    });

    this.nav.addEventListener("mouseleave", handleMouseLeave);

    const mainNavItemTween = TweenMax.to(this.cursorInner, 0.2, {
      scale: 0.8,
      borderColor: "#ffffff",
      ease: this.easing,
      paused: true
    });

    const mainNavItems = document.querySelectorAll(".demo-5 .content--fixed a");
    mainNavItems.forEach(item => {
      item.addEventListener("mouseenter", () => {
        mainNavItemTween.play();
      });
      item.addEventListener("mouseleave", () => {
        mainNavItemTween.reverse();
      });
    });
  }
github skaltenegger / customcursor / website / src / js / demo2.js View on Github external
initDemo() {
    const { Back } = window;
    this.cursor = document.querySelector(".arrow-cursor");
    this.cursorIcon = document.querySelector(".arrow-cursor__icon");
    this.cursorBox = this.cursor.getBoundingClientRect();
    this.easing = Back.easeOut.config(1.7);
    this.animationDuration = 0.3;
    this.cursorSide = null; // will be "left" or "right"
    this.cursorInsideSwiper = false;

    // initial cursor styling
    TweenMax.to(this.cursorIcon, 0, {
      rotation: -135,
      opacity: 0,
      scale: 0.5
    });

    document.addEventListener("mousemove", e => {
      this.clientX = e.clientX;
      this.clientY = e.clientY;
    });

    const render = () => {
      TweenMax.set(this.cursor, {
        x: this.clientX,
        y: this.clientY
      });
      requestAnimationFrame(render);
github skaltenegger / customcursor / website / src / js / demo3.js View on Github external
this.isStuck = false;
      TweenMax.to(this.outerCursor, 0.2, {
        width: this.outerCursorOriginals.width,
        height: this.outerCursorOriginals.height,
        opacity: 0.2,
        borderColor: "#ffffff"
      });
    };

    const linkItems = document.querySelectorAll(".browser-window__link");
    linkItems.forEach(item => {
      item.addEventListener("mouseenter", handleMouseEnter);
      item.addEventListener("mouseleave", handleMouseLeave);
    });

    const mainNavHoverTween = TweenMax.to(this.outerCursor, 0.3, {
      backgroundColor: "#ffffff",
      ease: this.easing,
      paused: true
    });

    const mainNavMouseEnter = () => {
      this.outerCursorSpeed = 0;
      TweenMax.set(this.innerCursor, { opacity: 0 });
      mainNavHoverTween.play();
    };

    const mainNavMouseLeave = () => {
      this.outerCursorSpeed = 0.2;
      TweenMax.set(this.innerCursor, { opacity: 1 });
      mainNavHoverTween.reverse();
    };
github skaltenegger / customcursor / website / src / js / demo1.js View on Github external
});

    const pswpContainer = document.querySelector(".pswp__container");
    pswpContainer.addEventListener("mouseenter", handleMouseEnter);

    const mainNavItems = document.querySelectorAll(".content--fixed a");
    mainNavItems.forEach(el => {
      el.addEventListener("mouseenter", () => {
        this.mainNavHoverTween.play();
      });
      el.addEventListener("mouseleave", () => {
        this.mainNavHoverTween.reverse();
      });
    });

    this.bumpCursorTween = TweenMax.to(this.outerCursor, 0.1, {
      scale: 0.7,
      paused: true,
      onComplete: () => {
        TweenMax.to(this.outerCursor, 0.2, {
          scale: 1,
          ease: this.easing
        });
      }
    });
  }
github skaltenegger / customcursor / website / src / js / demo2.js View on Github external
const onSwiperMouseLeave = e => {
      this.swiperBox = e.target.getBoundingClientRect();

      let outRotation = 0;
      if (this.clientY < this.swiperBox.top + this.swiperBox.height / 2) {
        outRotation = this.cursorSide === "right" ? -135 : -45;
      } else {
        outRotation = this.cursorSide === "right" ? 135 : -315;
      }

      TweenMax.to(this.cursorIcon, this.animationDuration, {
        rotation: outRotation,
        opacity: 0,
        scale: 0.3
      });

      this.cursorSide = null;
      this.cursorInsideSwiper = false;
    };
github skaltenegger / customcursor / website / src / js / demo3.js View on Github external
const render = () => {
      TweenMax.set(this.innerCursor, {
        x: this.clientX,
        y: this.clientY
      });
      if (!this.isStuck) {
        TweenMax.to(this.outerCursor, this.outerCursorSpeed, {
          x: this.clientX - this.outerCursorBox.width / 2,
          y: this.clientY - this.outerCursorBox.height / 2
        });
      }
      if (this.showCursor) {
        document.removeEventListener("mousemove", unveilCursor);
      }
      requestAnimationFrame(render);
    };
    requestAnimationFrame(render);
github skaltenegger / customcursor / website / src / js / demo4.js View on Github external
const mainNavItemMouseLeave = () => {
      this.outerCursorSpeed = 0.2;
      this.fillOuterCursor = false;
      TweenMax.to(this.innerCursor, 0.2, { opacity: 1 });
    };
github rezozero / starting-blocks / examples / src / js / transitions / BigTransition.js View on Github external
return new Promise((resolve) => {
            TweenMax.to(this.oldPage.rootElement, 0.75, {
                alpha: 0
            })

            TweenMax.set(this.mainElement, {
                autoAlpha: 1,
                onComplete: () => {
                    TweenMax.staggerTo(this.horizontalElements, 0.5, {
                        scaleX: 1
                    }, 0.1)

                    TweenMax.staggerTo(this.verticalElements.reverse(), 0.5, {
                        scaleY: 1
                    }, 0.1, resolve)
                }
            })
        })
github skaltenegger / customcursor / website / src / js / demo2.js View on Github external
}
    });
    this.swiper.on("touchMove", e => {
      const { clientX, clientY } = e;
      this.clientX = clientX;
      this.clientY = clientY;

      this.cursorSide = this.clientX > window.innerWidth / 2 ? "right" : "left";

      TweenMax.to(this.cursorIcon, this.animationDuration, {
        rotation: this.cursorSide === "right" ? 0 : -180,
        ease: this.easing
      });
    });

    this.bumpCursorTween = TweenMax.to(this.cursor, 0.1, {
      scale: 0.85,
      onComplete: () => {
        TweenMax.to(this.cursor, 0.2, {
          scale: 1,
          ease: this.easing
        });
      },
      paused: true
    });

    this.swiper.on("slideChange", () => {
      this.bumpCursorTween.play();
    });
  }
}

gsap

GSAP is a framework-agnostic JavaScript animation library that turns developers into animation superheroes. Build high-performance animations that work in **every** major browser. Animate CSS, SVG, canvas, React, Vue, WebGL, colors, strings, motion paths,

Standard 'no charge' license:…
Latest version published 4 months ago

Package Health Score

69 / 100
Full package analysis