Scrollmagic: Overriding scrollmagic scrollTo to animate it does nothing at all. No errors either.

Created on 10 Dec 2015  路  3Comments  路  Source: janpaepke/ScrollMagic

I have this code which should scrollTo the selected scene and it should be animated:

$('.scroll-trigger').click( function(e) {
                e.preventDefault();

                controller.scrollTo(function(target) {

                    TweenMax.to(window, 0.5, {
                        scrollTo : {
                            y : target, // scroll position of the target along y axis
                            autoKill : true // allows user to kill scroll action smoothly
                        },
                        ease : Cubic.easeInOut
                    });

                });

                controller.scrollTo(".edge-to-edge-image-wrapper:first-child",5000);
            });

That does nothing, but just going to the scene without the animation works fine:

$('.scroll-trigger').click( function(e) {
                e.preventDefault();

                controller.scrollTo(".edge-to-edge-image-wrapper:first-child",5000);
            });

Most helpful comment

@johnwbaxter I know this is old, but incase anyone stumbles across this, you need to include the ScrollTo plugin

eg. import ScrollToPlugin from "gsap/ScrollToPlugin"

All 3 comments

@johnwbaxter I know this is old, but incase anyone stumbles across this, you need to include the ScrollTo plugin

eg. import ScrollToPlugin from "gsap/ScrollToPlugin"

Following code also work for scroll
controller.scrollTo(function(newScrollPos) { $("html, body").animate({ scrollTop: newScrollPos }); }); controller.scrollTo(100);

Close this issue?

Was this page helpful?
0 / 5 - 0 ratings