Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Page Tailoring

How can I use GSAP 3 with scroll magic?

Recommended Posts

Hello ^_^
When i import scrollMagic files via npm , it gives me error and says: "Uncaught ReferenceError: TweenMax is not defined" , in Gsap2 I was importing TweenMax by hand and it helped,  but in Gsap3 i don't know how to do it, can you help me? 

Thank you

Share this post


Link to post
Share on other sites

Hey @salyone. You should be able to import it using the following: import { TweenMax } from "gsap". However, you can replace TweenMax with the gsap object in GSAP 3 as covered in the Top 5 GSAP 3 Features article (that's the more preferable solution).

  • Like 1

Share this post


Link to post
Share on other sites

Hi, all :) 

 

I resigned from "animations.gsap" ScrollMagic plugin and handle this like that:

 

 

import { gsap } from "gsap";
import ScrollMagic from 'ScrollMagic';

const controller = new ScrollMagic.Controller();

const easeInOut = 'circ.easeInOut';
const time = .5;

const menuAnim = gsap.timeline({defaults:{ease: easeInOut, duration: time}})
	.to('nav', {y: '-100%'})
	.to('#logo', {opacity: 1}, "-=0.4")
	.to('.main-nav', {opacity: 1}, "-=0.4")
	;
menuAnim.pause();	          

new ScrollMagic.Scene({
    triggerElement: '#home',
    duration:0,
    triggerHook: .85
    })
    .on("enter", function (e) {
        menuAnim.play();
    })
    .on("leave", function (e) {
        menuAnim.reverse();
    })
    .addTo(controller);

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×