janpaepke / ScrollMagic

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

Reverse(false) / triggers ignored #465

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi, I've been having issues with adding reverse(false) to a scene to prevent it from playing back when scrolled up. If there is only one scene in the file, everything works well. If I use exactly the same code in a file with multiple scenes,reverse:false does indeed disable animation on scrolling up, BUT it also seems to ignore triggers. I've tried debugging it and it says that scene is entered/left straight after the page loads.

Here is the code:

    var controller = new ScrollMagic.Controller();
    var scene = new ScrollMagic.Scene({ triggerElement: ".storelocator", triggerHook: 'onEnter',   offset: 250, loglevel:3}).setTween(TweenMax.staggerFrom('.storeitem', 1, { autoAlpha: 0, y: '+=50' }, 0.2) )
       .addIndicators()
       .addTo(controller);
       scene.on('enter', function (event) {
        console.log("Scene entered.");
        console.log(scene.triggerPosition());
    });
    scene.on('leave', function (event) {
        console.log("Scene left.");

I would be grateful for any help. Thanks.

webdobe commented 8 years ago

I am running into almost the same issue I think.... Basically if I have triggerHook as 'onEnter', and reverse set to false. The trigger happens the first time. But as soon as I scroll back up then scroll down to retrigger, I would assume that the trigger would refire... but it does not.

webdobe commented 8 years ago

What I ended up doing was leaving reverse default as true. Then doing option: C found here: https://github.com/janpaepke/ScrollMagic/wiki/WARNING:-tween-was-overwritten-by-another I am just going to guess this is the same issue.