Skip to content

Instantly share code, notes, and snippets.

@evansoderberg
Last active December 11, 2015 20:09
Show Gist options
  • Select an option

  • Save evansoderberg/4653535 to your computer and use it in GitHub Desktop.

Select an option

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.
$(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