Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Add class only when browser scrolling

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #37396
    elcape16
    Member

    The title pretty much describe what my problem is, I need to add a class to a fixed nav but only when the browser is scrolling if the user is not scrolling remove that class.

    Thanks in advance….
    Alex

    #100181
    cpyle0819
    Participant

    I am…intrigued. Are there any examples out there that you can link?

    #100183
    elcape16
    Member

    Not that I know, just a problem that I have and that will solve it

    #100184
    Mottie
    Member

    I’m not sure why you’d do this, but check out this demo and code:

    $(function() {

    var timer, el = $('body'),
    flag = false;
    $(window).scroll(function() {
    if (!flag) {
    flag = true;
    el.addClass('scrolling');
    }
    clearTimeout(timer);
    timer = setTimeout(function() {
    el.removeClass('scrolling');
    flag = false;
    }, 200);
    });

    });​
    #100187
    elcape16
    Member

    Just what I need! but is not working on my page

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.