Javascript counter issue
<p>I'm working now with site with paralaxx effect. I catch mouse position from window. If mouse  on top window.InnerHeight / 100 * 20 i will get window.mouseposition = "top" and window.mouseposition = "bottom". </p>

<p>I have issue in function i get broken counter.</p>

<p>But when dom is loaded, i have var currentSlide = 0; and i have event:</p>

<pre><code>    &lt;div id="slide1&gt;&lt;/div&gt;
    &lt;div id="slide2&gt;&lt;/div&gt;
    &lt;div id="slide3&gt;&lt;/div&gt;
    &lt;div id="slide4&gt;&lt;/div&gt; 

view.on('click',function(){
    if(window.mouseposition == "up" &amp;&amp; currentSlide &lt;= slide.length &amp;&amp; currentSlide != 0){
        goToByAttr(currentSlide -=1);
    }
    if(window.mouseposition == "bottom" &amp;&amp; currentSlide &lt; slide.length){
        goToByAttr(currentSlide +=1);
    }
});

        function goToByAttr(dataslide) {
            console.log(currentSlide);
            var element2 = document.getElementById("slide"+dataslide);
            view.stop().animate({
                scrollTop: getOffsetSum(element2).top
            }, 1000, 'easeInOutQuint');
            currentSlide = dataslide;
            return currentSlide
        }
</code></pre>

<p>When i click in the first time on the bottom, browser returns 1,2. And it scrolls to slide 2, but need 1.
But browser must return only 1; and then 2.</p>

<p>If i click on the top from 2, browser returns 1,0; And it scrolls to slide 0, but need 1.</p>

<p>Please help, why i get it?</p>
