Jump to content
Search Community

ScrollMagic: How to recalculate scene height and tween parameters?

honestbitchnosorry test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I am using the wipe effect for my website: http://scrollmagic.io/examples/advanced/section_wipes_manual.html

Each layer is auto height.

 

My current code is like this:

onst wipeAnimation = new TimelineMax()
        .to(".panel.one .layer", 2, {
          y: -panelOneScrollHeight,
          ease: Linear.easeNone
        })
        .to(".panel.one", 1, { y: "-100%", ease: Linear.easeNone })
        .to(".panel.two .layer", 1, {
          y: -panelTwoScrollHeight,
          ease: Linear.easeNone
        })
        .to(".panel.two", 1, { y: "-100%", ease: Linear.easeNone })
        .to(".panel.three .layer", 1, { y: "-100%", ease: Linear.easeNone })
        .to(".panel.three", 1, { y: "-100%", ease: Linear.easeNone })
        .to(".panel.four .layer", 2.5, {
          y: -panelFourScrollHeight,
          ease: Linear.easeNone
        })
        .to(".panel.four", 1, { y: "-100%", ease: Linear.easeNone })
        .to(".panel.five .layer", .5, { y: -(panelFiveScrollHeight), ease: Linear.easeNone });

      // create scene to pin and link animation
      new ScrollMagic.Scene({
        triggerElement: ".pinContainer",
        triggerHook: "onLeave",
        duration: "1100%"
      })
        .setPin(".pinContainer")
        .setTween(wipeAnimation)
        .on("progress", function(event) {
        //   console.log("Scene progress changed to " + event.progress);
          if (
            (event.progress > 0.266 && event.progress < 0.448) ||
            event.progress > 0.948
          ) {
            headerLogo.classList.add("primary");
          } else {
            headerLogo.classList.remove("primary");
          }
        })
        .addTo(controller);

 

 

The thing is, a certain page (or layer) has dynamic content that will affect the height (such as accordion, when you expand the content, this action will affect the height of the page). I need Scrollmagic to recalculate the height. How can I do it?

 

Please see the following images. The first one is when accordions are not expanded. The second one is when an accordion is expended. See how it messes up the page. So I need ScrollMagic to calculate the height and stuff. What's the way to do it?

 

Thanks.

 

Screenshot 2018-09-06 12.15.31.jpg

Screenshot 2018-09-06 12.17.00.jpg

Link to comment
Share on other sites

I'm not sure I understand the question and there is no demo included, but it sounds like you'd want to look at the refresh() method.

http://scrollmagic.io/docs/ScrollMagic.Scene.html#refresh 

 

I think all of your questions since joining the GS forum have been about ScrollMagic and I've answered several for you, but ScrollMagic is not a GreenSock product. They do have a support area here:

https://github.com/janpaepke/ScrollMagic/issues

 

We're happy to help with GSAP related questions and problems. Including a demo will get you the best possible answers.

 

Happy tweening.

 

  • Like 4
Link to comment
Share on other sites

1 hour ago, PointC said:

I'm not sure I understand the question and there is no demo included, but it sounds like you'd want to look at the refresh() method.

http://scrollmagic.io/docs/ScrollMagic.Scene.html#refresh 

 

I think all of your questions since joining the GS forum have been about ScrollMagic and I've answered several for you, but ScrollMagic is not a GreenSock product. They do have a support area here:

https://github.com/janpaepke/ScrollMagic/issues

 

We're happy to help with GSAP related questions and problems. Including a demo will get you the best possible answers.

 

Happy tweening.

 

 

Thanks for your help. I greatly appreciate it.

 

After some tinkering, removing the tween scene.removeTween() and then re-setting it Scene.setTween solves the problem for me.

Turns out it's not really about ScrollMagic, but the tween parameters.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...