Created
August 27, 2016 19:16
-
-
Save spac3unit/0c252d2d8cb8d4a9f893d804b465fce1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Depency on Jquery + http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js [Must Include] | |
if (window.addEventListener) window.addEventListener('DOMMouseScroll', wheel, false); | |
window.onmousewheel = document.onmousewheel = wheel; | |
function wheel(event) { | |
var delta = 0; | |
if (event.wheelDelta) delta = event.wheelDelta / 120; | |
else if (event.detail) delta = -event.detail / 3; | |
handle(delta); | |
if (event.preventDefault) event.preventDefault(); | |
event.returnValue = false; | |
} | |
function handle(delta) { | |
var time = 1000; // delay time | |
var distance = 300; // delta point | |
// Dom where it will apply | |
$('html, body').stop().animate({ | |
scrollTop: $(window).scrollTop() - (distance * delta) | |
}, time ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment