Skip to content

Instantly share code, notes, and snippets.

@QwertyZW
Created June 9, 2017 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QwertyZW/8f1025105aa5799731c809048a9cb509 to your computer and use it in GitHub Desktop.
Save QwertyZW/8f1025105aa5799731c809048a9cb509 to your computer and use it in GitHub Desktop.
Break mousewheel scroll movement with jquery
<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