I'm trying to move an element as the user scrolls.
If possible, to a class on scroll up and from a class on scroll down.
I want the element to move along with the scroll only if a certain condition is true.
So, I want the element to move down as the user scrolls up, if hasScrolledUp and scrollingUp are both true.
Then I want the element to move up as the user scrolls down, if downAfterUp is true.
Here is code that I have that sets those booleans:
    var lScrollTop = 0;
    var hasScrolledUp = false;
    var scrollingUp = false;
    var downAfterUp = false;
    $(window).scroll(function(){
        var scrollTop = $(this).scrollTop();
        if(scrollTop>lScrollTop){
            hasScrolledUp = true;
            scrollingUp = true;
        }
        else{
            if(scrollingUp) scrollingUp = false;
            if(hasScrolledUp) downAfterUp = true;
        }
        lScrollTop = scrollTop;
    });
I would greatly appreciate any and all help!