Last active
December 11, 2015 20:09
-
-
Save evansoderberg/4653535 to your computer and use it in GitHub Desktop.
This function allows an element to scroll sideways when the mouse wheel (up and down) is used. When the element reaches at value in pixels (3500 here), another event will be triggered.
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
| $(function() { | |
| $("*").mousewheel(function(event, delta) { | |
| var scroll = document.getElementById("wrapper"); | |
| scroll.scrollLeft -= (delta * 10); | |
| event.preventDefault(); | |
| if ($('#wrapper').scrollLeft() < 3500) { | |
| $('#textBox').removeClass('visible'); // or perform another action such as animate | |
| $('#textBox').addClass('hidden'); // toggleClass also is an option | |
| } else { | |
| $('#textBox').addClass('visible'); | |
| $('#textBox').removeClass('hidden'); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment