Created
June 9, 2017 23:01
-
-
Save QwertyZW/8f1025105aa5799731c809048a9cb509 to your computer and use it in GitHub Desktop.
Break mousewheel scroll movement with jquery
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
<html> | |
<body> | |
<div class="long-div"> | |
</div> | |
<style> | |
.long-div{ | |
height:3000px; | |
width:400px; | |
background: linear-gradient( 0deg, blue, green 50%, red ); | |
} | |
</style> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<script> | |
(function(jquery){ | |
$(window).bind('mousewheel DOMMouseScroll', function(event){ | |
if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) { | |
console.log('up') | |
event.preventDefault() | |
} | |
else { | |
console.log('down') | |
event.preventDefault() | |
} | |
}) | |
})($) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment