Sha256: 8cd3efdbb42fc47f01b0e9e7ea0e8d000e0641abcd861af934e939246a7d44b2

Contents?: true

Size: 1.54 KB

Versions: 9

Compression:

Stored size: 1.54 KB

Contents

/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * Version: 3.0.3-pre
 * 
 * Requires: 1.2.2+
 */

(function($) {

var types = ['DOMMouseScroll', 'mousewheel'];

$.event.special.mousewheel = {
    setup: function() {
        if ( this.addEventListener )
            for ( var i=types.length; i; )
                this.addEventListener( types[--i], handler, false );
        else
            this.onmousewheel = handler;
    },
    
    teardown: function() {
        if ( this.removeEventListener )
            for ( var i=types.length; i; )
                this.removeEventListener( types[--i], handler, false );
        else
            this.onmousewheel = null;
    }
};

$.fn.extend({
    mousewheel: function(fn) {
        return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
    },
    
    unmousewheel: function(fn) {
        return this.unbind("mousewheel", fn);
    }
});


function handler(event) {
    var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true;
    
    event = $.event.fix(event || window.event);
    event.type = "mousewheel";
    
    if ( event.wheelDelta ) delta = event.wheelDelta/120;
    if ( event.detail     ) delta = -event.detail/3;
    
    // Add event and delta to the front of the arguments
    args.unshift(event, delta);

    return $.event.handle.apply(this, args);
}

})(jQuery);

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
locomotive-aloha-rails-0.20.1.5 vendor/assets/javascripts/aloha/plugins/common/image/vendor/mousewheel/mousewheel.js
aloha-rails-0.0.2 vendor/assets/javascripts/aloha/plugins/common/image/vendor/mousewheel/mousewheel.js
free_text-0.0.3 app/assets/javascripts/aloha-0.10.0/plugins/common/image/vendor/mousewheel/mousewheel.js
locomotive-aloha-rails-0.20.1.4 vendor/assets/javascripts/aloha/plugins/common/image/vendor/mousewheel/mousewheel.js
locomotive-aloha-rails-0.20.1.3 vendor/assets/javascripts/aloha/plugins/common/image/vendor/mousewheel/mousewheel.js
locomotive-aloha-rails-0.20.1.2 vendor/assets/javascripts/aloha/plugins/common/image/vendor/mousewheel/mousewheel.js
locomotive-aloha-rails-0.20.1.1 vendor/assets/javascripts/aloha/plugins/common/image/vendor/mousewheel/mousewheel.js
aloha-rails-0.0.1 vendor/assets/javascripts/aloha/plugins/common/image/vendor/mousewheel/mousewheel.js
locomotive-aloha-rails-0.20.1 vendor/assets/javascripts/aloha/plugins/common/image/vendor/mousewheel/mousewheel.js