Jump to content
GreenSock

pedriveros

Scrollmagic

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

Hi,

I find GSAP to be very useful and easy to implement according the needs of each project I'm in, but there's something I'd like to do with no luck so far.

Using Scrollmagic, I've set a scene manipulation where each section overlaps the previous one, but I need to kill it after the last one, so it doesn't feel pinned, so the next part of the DOM starts displaying normally as the page keeps scrolling down

 

I include a .zip if it could be required

 

Thanks for your support

demo.zip

Link to comment
Share on other sites

Perhaps someone else would be wiling to chime in and help (I hope so) but this sounds like a ScrollMagic question and we really try to keep these forums focused on GSAP specifically. We didn't create (nor do we support) ScrollMagic. Did you try contacting the author of ScrollMagic? 

  • Like 1
Link to comment
Share on other sites

Thanks for the feedback

Actually, I have not, but that's actually not a bad advise, thanks for the great support (friendly and trustful).

Whenever I get with the solution, I'll be posting it here just in case this could of any help

  • Like 1
Link to comment
Share on other sites

Perfect, we'd love to hear about any solutions you come up with. It could benefit others who have the same question. Thanks!

Link to comment
Share on other sites

Here's a Codepen unpinning the Section 3 and displaying the following content normally.

 

See the Pen QjRWGM by ihatetomatoes (@ihatetomatoes) on CodePen

 

This is the approach:

 

- create new "unpin element" inside of Section 3 and position it at the bottom

- create a new scene, that will unpin Section 3

- trigger this scene when "unpin element" comes into a view

 

This will unpin Section 3, but both Section 1 and 2 are still pinned, that's why you have to also add white background to Section 3 and change background colors of Section 1 and 2 to white.

 

Here's the updated ScrollMagic code:

var scene;

var controller2 = new ScrollMagic.Controller({
    globalSceneOptions: {
        triggerHook: "onLeave"
    }
});

var controller = new ScrollMagic.Controller({
    globalSceneOptions: {
        triggerHook: "onEnter"
    }
});

var slides = document.querySelectorAll("div.layer");
for (var i=0; i<slides.length; i++) {
    scene = new ScrollMagic.Scene({
        triggerElement: slides[i]
    })
    .setPin(slides[i])
    .addIndicators()
    .addTo(controller2);
}

var unpinSlide = document.querySelectorAll("div.unpin");
var scene2 = new ScrollMagic.Scene({
    triggerElement: unpinSlide[0]
})
.addIndicators({
    colorStart: "rgba(255,255,255,0.5)",
    colorEnd: "rgba(255,255,255,0.5)", 
    colorTrigger : "rgba(255,255,255,1)",
    name: 'unpin'
})
.setClassToggle(".bg-blue, .bg-red", "bg-white")
.on("enter", function (e) {
    scene.destroy(true);
})
.addTo(controller);

Hope that helps.

  • Like 4
Link to comment
Share on other sites

Thanks Petr.

This is exactly what I was looking for, and now I hope others can make good ouse of it

 

Thanks for sharing with us.

  • Like 1
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.
×