janpaepke / ScrollMagic

The javascript library for magical scroll interactions.
http://ScrollMagic.io
Other
14.88k stars 2.17k forks source link

Overriding scrollmagic scrollTo to animate it does nothing at all. No errors either. #456

Open johnwbaxter opened 8 years ago

johnwbaxter commented 8 years ago

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);
            });
jshrssll commented 6 years ago

@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"

BharatBhatiya commented 6 years ago

Following code also work for scroll

                           controller.scrollTo(function(newScrollPos) {
                                $("html, body").animate({
                                    scrollTop: newScrollPos
                                });
                            });
                            controller.scrollTo(100);
krnlde commented 6 years ago

Close this issue?