I have several divs, all with the same class (post), and I have a simple navigation with UP and DOWN.
<nav>
<a href="" id="down">Down</a>
<a href="" id="up">Up</a>
</nav>
<div class="post one">Lorem ipsum dolor sit amet.</div>
<div class="post two">Lorem ipsum dolor sit amet.</div>
<div class="post three">Lorem ipsum dolor sit amet.</div>
Everytime the user clicks in Down I want to scroll down one div at the time. Everytime the users click Up I want to go up one div at the time.
I almost got it, but there are some errors if you click down twice and then you want to go up twice again, then the scroller gets stuck in the middle. Also if you are at the very bottom and you click Down one more time, it starts from the top. Also if you click one up and one down, the scrolling it's not following the logic that it should.
Please see it here: http://jsfiddle.net/grovve/bs6443y4/
I assume it's something connected with my variable "$currentElement" and what is exactly the value of this variable at a given time, am I right? What exactly am I missing to make it work as it should?