Skip to content

Instantly share code, notes, and snippets.

@kolber
Created February 6, 2012 07:15
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 kolber/1750391 to your computer and use it in GitHub Desktop.
Save kolber/1750391 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name theglobalmail.org reverse scrolling
// @description Flips scrolling on theglobalmail.org articles.
// @namespace anthonykolber
// @include http://www.theglobalmail.org/*
// @version 0.0.1
// @contributor anthonykolber
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js
// ==/UserScript==
jQuery.noConflict();
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(i){var g=i||window.event,f=[].slice.call(arguments,1),j=0,h=true,e=0,d=0;i=c.event.fix(g);i.type="mousewheel";if(i.wheelDelta){j=i.wheelDelta/120}if(i.detail){j=-i.detail/3}d=j;if(g.axis!==undefined&&g.axis===g.HORIZONTAL_AXIS){d=0;e=-1*j}if(g.wheelDeltaY!==undefined){d=g.wheelDeltaY/120}if(g.wheelDeltaX!==undefined){e=-1*g.wheelDeltaX/120}f.unshift(i,j,e,d);return c.event.handle.apply(this,f)}})(jQuery);
jQuery(function() {
alert('loaded');
$('body').mousewheel(function(e, delta) {
var doc = $(document),
pos = doc.scrollLeft() - (delta *= 20);
doc.scrollLeft(pos);
e.preventDefault();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment