Skip to content

Instantly share code, notes, and snippets.

View JoshuaToenyes's full-sized avatar

Joshua Toenyes JoshuaToenyes

View GitHub Profile
@JoshuaToenyes
JoshuaToenyes / hscroll.js
Last active June 15, 2016 16:33
Prevent "back" and "forward" swipe navigation in Chrome for horizontal scrolling in some element.
(function ($) {
$(document).on('mousewheel', function(e) {
var $target = $(e.target).closest('.scrollable-h');
var scroll = $target.scrollLeft();
var maxScroll = $target.find('.scrollable-h-content').width() - $target.width();
if(scroll <= 0) {
// Prevent "back" navigation.
if(scroll <= 0 && e.originalEvent.wheelDeltaX > 0) {
e.preventDefault();