Skip to content

Commit

Permalink
Merge pull request #6 from bodrovis/master
Browse files Browse the repository at this point in the history
Version 3.1.9. Also added license to gemspec
  • Loading branch information
crazymykl committed Dec 26, 2013
2 parents 08812d3 + bf65cdd commit 4d5ef37
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
jquery-mousewheel-rails (0.0.6)
jquery-mousewheel-rails (0.0.7)
railties (>= 3.1)

GEM
Expand Down
1 change: 1 addition & 0 deletions jquery-mousewheel-rails.gemspec
Expand Up @@ -15,6 +15,7 @@ Gem::Specification.new do |s|
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.require_paths = ["lib"]
s.license = 'MIT'

s.add_runtime_dependency 'railties', '>= 3.1'
s.add_development_dependency "sqlite3"
Expand Down
2 changes: 1 addition & 1 deletion lib/jquery-mousewheel-rails/version.rb
@@ -1,3 +1,3 @@
module JqueryMousewheelRails
VERSION = "0.0.6"
VERSION = "0.0.7"
end
36 changes: 23 additions & 13 deletions vendor/assets/javascripts/jquery.mousewheel.js
@@ -1,7 +1,7 @@
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
* Licensed under the MIT License (LICENSE.txt).
*
* Version: 3.1.8
* Version: 3.1.9
*
* Requires: jQuery 1.2.2+
*/
Expand All @@ -21,9 +21,9 @@

var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
slice = Array.prototype.slice,
oldMode, nullLowestDeltaTimeout, lowestDelta;
nullLowestDeltaTimeout, lowestDelta;

if ( $.event.fixHooks ) {
for ( var i = toFix.length; i; ) {
Expand All @@ -32,7 +32,7 @@
}

var special = $.event.special.mousewheel = {
version: '3.1.8',
version: '3.1.9',

setup: function() {
if ( this.addEventListener ) {
Expand Down Expand Up @@ -63,6 +63,10 @@

getPageHeight: function(elem) {
return $(elem).height();
},

settings: {
adjustOldDeltas: true
}
};

Expand Down Expand Up @@ -138,18 +142,14 @@
if ( !lowestDelta || absDelta < lowestDelta ) {
lowestDelta = absDelta;

// Assuming that if the lowestDelta is 120, then that the browser
// is treating this as an older mouse wheel event.
// We'll divide it by 40 to try and get a more usable deltaFactor.
if ( lowestDelta === 120 ) {
oldMode = true;
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
lowestDelta /= 40;
}
}

// When in oldMode the delta is based on 120.
// Dividing by 40 to try and get a more usable deltaFactor.
if ( oldMode ) {
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
// Divide all the things by 40!
delta /= 40;
deltaX /= 40;
Expand Down Expand Up @@ -185,7 +185,17 @@

function nullLowestDelta() {
lowestDelta = null;
oldMode = null;
}

function shouldAdjustOldDeltas(orgEvent, absDelta) {
// If this is an older event and the delta is divisable by 120,
// then we are assuming that the browser is treating this as an
// older mouse wheel event and that we should divide the deltas
// by 40 to try and get a more usable deltaFactor.
// Side note, this actually impacts the reported scroll distance
// in older browsers and can cause scrolling to be slower than native.
// Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
}

}));

0 comments on commit 4d5ef37

Please sign in to comment.