Created
March 4, 2015 12:49
-
-
Save gucheen/aa96f0d6f63633117b1d to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/wecovo
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
body { | |
height: 3000px; | |
} | |
.scroll { | |
background: green; | |
width: 200px; | |
height: 300px; | |
overflow-y: scroll; | |
} | |
.content { | |
height: 800px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="scroll"> | |
<div class="content"></div> | |
</div> | |
<script id="jsbin-javascript"> | |
var scroll = document.getElementsByClassName('scroll')[0]; | |
var content = document.getElementsByClassName('content')[0]; | |
function handleScroll (e) { | |
if (e.deltaY < 0 && scroll.scrollTop === 0) { | |
e.preventDefault(); | |
} | |
if (e.deltaY > 0 && (scroll.scrollTop + scroll.offsetHeight) >= scroll.scrollHeight) { | |
e.preventDefault(); | |
} | |
} | |
scroll.addEventListener('mousewheel', handleScroll); | |
</script> | |
<script id="jsbin-source-css" type="text/css">body { | |
height: 3000px; | |
} | |
.scroll { | |
background: green; | |
width: 200px; | |
height: 300px; | |
overflow-y: scroll; | |
} | |
.content { | |
height: 800px; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var scroll = document.getElementsByClassName('scroll')[0]; | |
var content = document.getElementsByClassName('content')[0]; | |
function handleScroll (e) { | |
if (e.deltaY < 0 && scroll.scrollTop === 0) { | |
e.preventDefault(); | |
} | |
if (e.deltaY > 0 && (scroll.scrollTop + scroll.offsetHeight) >= scroll.scrollHeight) { | |
e.preventDefault(); | |
} | |
} | |
scroll.addEventListener('mousewheel', handleScroll);</script></body> | |
</html> |
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
body { | |
height: 3000px; | |
} | |
.scroll { | |
background: green; | |
width: 200px; | |
height: 300px; | |
overflow-y: scroll; | |
} | |
.content { | |
height: 800px; | |
} |
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
var scroll = document.getElementsByClassName('scroll')[0]; | |
var content = document.getElementsByClassName('content')[0]; | |
function handleScroll (e) { | |
if (e.deltaY < 0 && scroll.scrollTop === 0) { | |
e.preventDefault(); | |
} | |
if (e.deltaY > 0 && (scroll.scrollTop + scroll.offsetHeight) >= scroll.scrollHeight) { | |
e.preventDefault(); | |
} | |
} | |
scroll.addEventListener('mousewheel', handleScroll); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment