Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duration is set to '0', but when scrolling past the triggerElement my Class toggles back #987

Open
jordan-umbrace opened this issue Jun 14, 2021 · 0 comments

Comments

@jordan-umbrace
Copy link

I'm using ScrollMagic to toggle a dark-mode class on the Body when scrolling past a certain Section(triggerElement). When the duration is set to '0', the toggle should be triggered, and only be re-triggered when scrolling back past the entry point. When I scroll past the end of the triggerElement for about 500 px or so (it is random), the class retoggles as if the duration is set. I have tried different things like giving each section that trigger class, but that only makes things worse. Does someone have an idea what is going on or what I am doing wrong?

` var controller = new ScrollMagic.Controller();

    $('.darkModeTrigger').each(function () {

        var scene = new ScrollMagic.Scene({
            triggerElement: this,
            duration: 0,
        }).setClassToggle('.body', 'is--dark-mode')
            .addIndicators({
                name: 'darkmode trigger',
                colorStart: 'red',
                colorEnd: 'pink'
            })
            .addTo(controller);
    });`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant