0

I hope someone can help me. Here is my project: http://jsfiddle.net/oz7bgL5v/8/

adjustNav: function(self, $parent) {
    self.$elem.find('.' + self.config.currentClass).removeClass(self.config.currentClass);
    $(".next").click();
    $parent.addClass(self.config.currentClass);                     
}

This works when scrolling down but not when scrolling up.

I just need to go back in pagination navigation (click "previous" button) when scrolling up (You intuitively can understand what I mean when you see my project.)

1 Answer 1

1

To detect going to 'previous' when scrolling up you need to keep track of the previous scroll location when you handle scrolling. Please see how I did it in this fiddle: http://jsfiddle.net/x74w3tcs/

Then your adjustNav function can look like this:

adjustNav: function(self, $parent, direction) {
    self.$elem.find('.' + self.config.currentClass).removeClass(self.config.currentClass);

    $parent.addClass(self.config.currentClass); 

    if (direction === 'up') {
        $(".prev").click();
    }   
    else {
        $(".next").click();
    }
},
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for your time. You have done me a great help. Thank you
You're welcome :) In your original code, the scroll event handler was just setting a flag which was checked later to call a function that adjusts the nav, when you can just call the function from the event handler (I changed this in my fiddle). Also there is probably a better way to handle checking if document height changes than setting an interval to check every 250ms; maybe .resize() will do what you want? api.jquery.com/resize
"Vote Up requires 15 reputation" :( Was trying from start.
Ah, you can click the check mark under the up/down arrows to accept the answer. Up vote is a different thing :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.