Skip to content

Instantly share code, notes, and snippets.

@niieani
Last active July 31, 2016 15:44
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 niieani/6a8830cb3b0564e7b16a4f31a9405386 to your computer and use it in GitHub Desktop.
Save niieani/6a8830cb3b0564e7b16a4f31a9405386 to your computer and use it in GitHub Desktop.
Scroll Wheel Pass-through
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="fixed">mouse wheel over this fixed content</div>
<div id="container">
<div id="content">Tall Content</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.0.slim.min.js"></script>
<script src="script.js"></script>
</body>
</html>
var target = $('#container').get(0);
$('#fixed').on('wheel', function (e) {
var o = e.originalEvent;
target.scrollTop += o.deltaY;
target.scrollLeft += o.deltaX;
});
body {
overflow: hidden;
}
#container {
height: 500px;
border: 1px solid blue;
overflow: scroll;
}
#content {
height: 1000px;
}
#fixed {
position: fixed;
right: 0px;
height: 100px;
width: 200px;
border: 1px solid red;
background: pink;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment