Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript Bind function to mouse wheel
    primarykey
    data
    text
    <p>I have a single page website that uses internal anchors to give the illusion of multiple pages. I have written a javascript function that reads the mousewheel up/down from the user and that based on that, sends the user to the anchor above/below the current page they are. The function is working properly as described however the mousewheel is so sensitive that the slightest move will fire multiple mousewheel events and send the user multiple pages up/down instead of just one.</p> <p>I need a way to limit how many times my mousewheel function can be executed so that the user only moves one page in either direction on the mousewheel regardless of fast/slow the mousewheel was used. My javascript is below.</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $("#main").bind('mousewheel', function(event) { if (event.originalEvent.wheelDelta &gt;= 0) { var currentPage = $(".active").attr('href'); switch(currentPage){ case "#publications": window.location = $("#menu-item-290 a").attr('href'); break; case "#branding": window.location = $("#menu-item-106 a").attr('href'); break; case "#website-development": window.location = $("#menu-item-110 a").attr('href'); break; case "#about-us": window.location = $("#menu-item-109 a").attr('href'); break; case "#contact": window.location = $("#menu-item-108 a").attr('href'); break; } } else { var currentPage = $(".active").attr('href'); switch(currentPage){ case "#home": window.location = $("#menu-item-106 a").attr('href'); break; case "#publications": window.location = $("#menu-item-110 a").attr('href'); break; case "#branding": window.location = $("#menu-item-109 a").attr('href'); break; case "#website-development": window.location = $("#menu-item-108 a").attr('href'); break; case "#about-us": window.location = $("#menu-item-107 a").attr('href'); break; } } }); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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