jquery-mousewheel-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 926dbfd82a567c8b45a271a292f9372fba28a516
4
- data.tar.gz: 21b9bbb2c2abebe586c90a4f00e7f8d363a36328
3
+ metadata.gz: 6d3c4c24f02fc3490eb09fcd6e16b6845deb7465
4
+ data.tar.gz: 1f12801a55323a678d450747b669a754e1b18b46
5
5
  SHA512:
6
- metadata.gz: 0e5566f3c60ddb3a9ebdba0b6f97f4f2ab96328644c36ee188550115d76b32d21407d6ec11985ab211723433b1ba403ab386c6bd42cba091eda3a5551100c12e
7
- data.tar.gz: 91c1a94ec4bdb3fc5d0910d3f95ec99f8f302444188cdb38ffe253025013c2a0925b39f7a115b381d0b48faf005ca21ffc4c26fd55685e03d57b7e22b3fca248
6
+ metadata.gz: 6ff6a0d8a9f26e69ade36eefa9314ef3ffa937fa3509059a68a02bb329eb8d0786197bfc1698b79536e0ebe9eaa37e3f0a2057895381941a536d7400b77c3f70
7
+ data.tar.gz: c044f0e8e17d22cc6f1ab8c3d5429380a450f4e477af90a316469cfed4dc8ac5ba40906b0ed4ddaf3b09f6694b225afdfcadf0deb4016765e748602207226148
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jquery-mousewheel-rails (0.0.4)
4
+ jquery-mousewheel-rails (0.0.5)
5
5
  railties (>= 3.1)
6
6
 
7
7
  GEM
@@ -38,7 +38,6 @@ GEM
38
38
  thor (>= 0.18.1, < 2.0)
39
39
  rake (10.1.0)
40
40
  sqlite3 (1.3.8)
41
- sqlite3 (1.3.8-x86-mingw32)
42
41
  thor (0.18.1)
43
42
  thread_safe (0.1.3)
44
43
  atomic
@@ -46,7 +45,6 @@ GEM
46
45
 
47
46
  PLATFORMS
48
47
  ruby
49
- x86-mingw32
50
48
 
51
49
  DEPENDENCIES
52
50
  jquery-mousewheel-rails!
@@ -1,3 +1,3 @@
1
1
  module JqueryMousewheelRails
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,9 +1,9 @@
1
1
  /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
2
2
  * Licensed under the MIT License (LICENSE.txt).
3
3
  *
4
- * Version: 3.1.4
4
+ * Version: 3.1.6
5
5
  *
6
- * Requires: 1.2.2+
6
+ * Requires: jQuery 1.2.2+
7
7
  */
8
8
 
9
9
  (function (factory) {
@@ -19,9 +19,11 @@
19
19
  }
20
20
  }(function ($) {
21
21
 
22
- var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'];
23
- var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'];
24
- var lowestDelta, lowestDeltaXY;
22
+ var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
23
+ toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
24
+ ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
25
+ slice = Array.prototype.slice,
26
+ nullLowestDeltaTimeout, lowestDelta;
25
27
 
26
28
  if ( $.event.fixHooks ) {
27
29
  for ( var i = toFix.length; i; ) {
@@ -30,6 +32,8 @@
30
32
  }
31
33
 
32
34
  $.event.special.mousewheel = {
35
+ version: '3.1.6',
36
+
33
37
  setup: function() {
34
38
  if ( this.addEventListener ) {
35
39
  for ( var i = toBind.length; i; ) {
@@ -64,59 +68,73 @@
64
68
 
65
69
  function handler(event) {
66
70
  var orgEvent = event || window.event,
67
- args = [].slice.call(arguments, 1),
71
+ args = slice.call(arguments, 1),
68
72
  delta = 0,
69
73
  deltaX = 0,
70
74
  deltaY = 0,
71
- absDelta = 0,
72
- absDeltaXY = 0,
73
- fn;
75
+ absDelta = 0;
74
76
  event = $.event.fix(orgEvent);
75
77
  event.type = 'mousewheel';
76
78
 
77
79
  // Old school scrollwheel delta
78
- if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; }
79
- if ( orgEvent.detail ) { delta = orgEvent.detail * -1; }
80
-
81
- // At a minimum, setup the deltaY to be delta
82
- deltaY = delta;
83
-
84
- // Firefox < 17 related to DOMMouseScroll event
85
- if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
80
+ if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
81
+ if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
82
+ if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
83
+ if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
84
+
85
+ // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
86
+ if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
87
+ deltaX = deltaY * -1;
86
88
  deltaY = 0;
87
- deltaX = delta * -1;
88
89
  }
89
90
 
91
+ // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
92
+ delta = deltaY === 0 ? deltaX : deltaY;
93
+
90
94
  // New school wheel delta (wheel event)
91
- if ( orgEvent.deltaY ) {
95
+ if ( 'deltaY' in orgEvent ) {
92
96
  deltaY = orgEvent.deltaY * -1;
93
97
  delta = deltaY;
94
98
  }
95
- if ( orgEvent.deltaX ) {
99
+ if ( 'deltaX' in orgEvent ) {
96
100
  deltaX = orgEvent.deltaX;
97
- delta = deltaX * -1;
101
+ if ( deltaY === 0 ) { delta = deltaX * -1; }
98
102
  }
99
103
 
100
- // Webkit
101
- if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; }
102
- if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX * -1; }
104
+ // No change actually happened, no reason to go any further
105
+ if ( deltaY === 0 && deltaX === 0 ) { return; }
103
106
 
104
- // Look for lowest delta to normalize the delta values
105
- absDelta = Math.abs(delta);
106
- if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; }
107
- absDeltaXY = Math.max(Math.abs(deltaY), Math.abs(deltaX));
108
- if ( !lowestDeltaXY || absDeltaXY < lowestDeltaXY ) { lowestDeltaXY = absDeltaXY; }
107
+ // Store lowest absolute delta to normalize the delta values
108
+ absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
109
+ if ( !lowestDelta || absDelta < lowestDelta ) {
110
+ lowestDelta = absDelta;
111
+ }
109
112
 
110
- // Get a whole value for the deltas
111
- fn = delta > 0 ? 'floor' : 'ceil';
112
- delta = Math[fn](delta / lowestDelta);
113
- deltaX = Math[fn](deltaX / lowestDeltaXY);
114
- deltaY = Math[fn](deltaY / lowestDeltaXY);
113
+ // Get a whole, normalized value for the deltas
114
+ delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
115
+ deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
116
+ deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
117
+
118
+ // Add information to the event object
119
+ event.deltaX = deltaX;
120
+ event.deltaY = deltaY;
121
+ event.deltaFactor = lowestDelta;
115
122
 
116
123
  // Add event and delta to the front of the arguments
117
124
  args.unshift(event, delta, deltaX, deltaY);
118
125
 
126
+ // Clearout lowestDelta after sometime to better
127
+ // handle multiple device types that give different
128
+ // a different lowestDelta
129
+ // Ex: trackpad = 3 and mouse wheel = 120
130
+ if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
131
+ nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
132
+
119
133
  return ($.event.dispatch || $.event.handle).apply(this, args);
120
134
  }
121
135
 
136
+ function nullLowestDelta() {
137
+ lowestDelta = null;
138
+ }
139
+
122
140
  }));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-mousewheel-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike MacDonald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-21 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.0.5
112
+ rubygems_version: 2.0.3
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Integrates jquery-mousewheel with rails.