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

(gumshoe) How to delay (debounce) spy adding active class to LI BUT ONLY after click event ? #112

Open
RobotHabanera opened this issue Oct 1, 2019 · 2 comments

Comments

@RobotHabanera
Copy link

RobotHabanera commented Oct 1, 2019

(gumshoe) How to delay (debounce) spy adding active class to LI BUT ONLY after click event ?
I tried this but to no avail:
Outside of plugin:

        $(".nav__menu .nav__item .nav__link").on("click", function(e) {

            activeREWQ = true;

            e.preventDefault();
            $(this).data('clicked', true);
            $('html,body').animate({
                scrollTop: $($.attr(this, 'href')).offset().top -57
            }, 800, function() {

                    activeREWQ = false;
            });
        });

...and then inside gumshoe plugin:

    if (activeREWQ) {
        $(window).scroll($.debounce(250, function () {
            li.classList.remove(settings.navClass);
            items.content.classList.remove(settings.contentClass);
        }));
    } else {
        li.classList.remove(settings.navClass);
        items.content.classList.remove(settings.contentClass);
    }

    if (activeREWQ) {
        $(window).scroll($.debounce(250, function () {
            li.classList.add(settings.navClass);
            items.content.classList.add(settings.contentClass);
        }));
    } else {
        li.classList.add(settings.navClass);
        items.content.classList.add(settings.contentClass);            
    }
@cferdinandi
Copy link
Owner

Sorry, I'm not entirely sure what you're trying to do. Gumshoe debounces automatically on scroll events.

@pradyunsg
Copy link

I think this issue can be closed due to lack of a response/activity over the checks date last 8 months.

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

3 participants