Note that there are some explanatory texts on larger screens.

plurals
  1. PODisable scrolling when the animation of scrolling is taking place
    primarykey
    data
    text
    <p>I am trying to create an scrolling animation when the user moves the mouse wheel up or down, press the the keyword arrows or move the scrolling bar in the side.</p> <p>It is pretty similar as what I found <a href="http://onlinedepartment.nl/about-us/" rel="nofollow noreferrer">on this site</a>. As I didn't find any jQuery plugin for it, I am trying to reproduce it by my own and I am having some troubles with the scrolling behavior.</p> <p>When the scrolling animation is taking place, you can still scrolling with the mouse wheel and it makes the movement look ugly, going up and down for a while.</p> <p>Here's my fiddle where you can check it: <a href="http://jsfiddle.net/k4rsN/1/" rel="nofollow noreferrer">http://jsfiddle.net/k4rsN/1/</a></p> <p>The problem is that the scrolling is not disable and before I can check if they are scrolling up or down, the site has already scrolled a bit (a movement of the wheel, or keyword). Therefor I believe the way to solve it is disabling the scrolling effect and letting me decide what to do when the user decides to scroll. </p> <p>I've been taking a look at posts like <a href="https://stackoverflow.com/questions/3656592/how-to-programmatically-disable-page-scrolling-with-jquery">this</a> or <a href="https://stackoverflow.com/questions/7600454/how-to-prevent-page-scrolling-when-scrolling-a-div-element">this</a> but it don't solve my problem.</p> <p>This is what I've done so far as you can see in <a href="http://jsfiddle.net/k4rsN/1/" rel="nofollow noreferrer">the fiddle</a>: </p> <pre><code>var lastScrollTop = 0; var isMoving = false; $(window).scroll(function () { var currentScroll = $(window).scrollTop(); //scrolling down? if (currentScroll &gt; lastScrollTop &amp;&amp; !isMoving) { var value = '#link2'; } //scrolling up? else if (!isMoving) { var value = '#link1'; } lastScrollTop = currentScroll; //animation if (value &amp;&amp; !isMoving) { //if theres any # isMoving = true; dest = $(value).offset(); $('html, body').animate({ scrollTop: dtop }, 1200, function () { //setting the flag to avoid checking the scrolling when performing the animation isMoving = false; }); } }); </code></pre> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload