Last active
July 31, 2016 15:44
-
-
Save niieani/6a8830cb3b0564e7b16a4f31a9405386 to your computer and use it in GitHub Desktop.
Scroll Wheel Pass-through
This file contains hidden or 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 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> |
This file contains hidden or 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 target = $('#container').get(0); | |
| $('#fixed').on('wheel', function (e) { | |
| var o = e.originalEvent; | |
| target.scrollTop += o.deltaY; | |
| target.scrollLeft += o.deltaX; | |
| }); |
This file contains hidden or 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 { | |
| 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