Changeset 1387
- Timestamp:
- 06/12/08 12:04:51 (3 months ago)
- Files:
-
- mochikit/trunk/MochiKit/Signal.js (modified) (3 diffs)
- mochikit/trunk/doc/html/MochiKit/Signal.html (modified) (3 diffs)
- mochikit/trunk/doc/rst/MochiKit/Signal.rst (modified) (2 diffs)
- mochikit/trunk/examples/mouse_events/mouse_events.js (modified) (1 diff)
- mochikit/trunk/packed/MochiKit/MochiKit.js (modified) (3 diffs)
- mochikit/trunk/tests/test_Signal.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mochikit/trunk/MochiKit/Signal.js
r1386 r1387 335 335 } 336 336 if (this.type() == 'mousewheel') { 337 m.wheel = e.detail ? e.detail : -e.wheelDelta / 40; 337 m.wheel = new MochiKit.Style.Coordinates(0, 0); 338 if (e.wheelDeltaX || e.wheelDeltaY) { 339 m.wheel.x = e.wheelDeltaX / -40 || 0; 340 m.wheel.y = e.wheelDeltaY / -40 || 0; 341 } else if (e.wheelDelta) { 342 m.wheel.y = e.wheelDelta / -40; 343 } else { 344 m.wheel.y = e.detail || 0; 345 } 338 346 } 339 347 this._mouse = m; … … 559 567 }, 560 568 561 _browser HasMouseWheelEvent: function () {562 return / MSIE/.test(navigator.userAgent) || /Opera/.test(navigator.userAgent);569 _browserLacksMouseWheelEvent: function () { 570 return /Gecko\//.test(navigator.userAgent); 563 571 }, 564 572 … … 636 644 sig = "onmouseout"; 637 645 } 638 } else if (isDOM && sig == "onmousewheel" && !self._browserHasMouseWheelEvent()) {646 } else if (isDOM && sig == "onmousewheel" && self._browserLacksMouseWheelEvent()) { 639 647 var listener = self._listener(src, sig, func, obj, isDOM); 640 648 sig = "onDOMMouseScroll"; mochikit/trunk/doc/html/MochiKit/Signal.html
r1386 r1387 5 5 <head> 6 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 7 <meta name="generator" content="Docutils 0.4 .1: http://docutils.sourceforge.net/" />7 <meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" /> 8 8 <title>MochiKit.Signal - Simple universal event handling</title> 9 9 … … 154 154 <p><tt class="docutils literal"><span class="pre">onmousewheel</span></tt></p> 155 155 <blockquote> 156 <p>Not strictly synthesized, but named <tt class="docutils literal"><span class="pre">'DOMMouseScroll'</span></tt> in Firefox157 and Safari browsers. MochiKit translates <tt class="docutils literal"><span class="pre">'onmousewheel'</span></tt> to the 158 correctevent in these browsers.</p>156 <p>Not strictly synthesized, but named <tt class="docutils literal"><span class="pre">'DOMMouseScroll'</span></tt> in 157 Gecko-based browsers. MochiKit translates <tt class="docutils literal"><span class="pre">'onmousewheel'</span></tt> to 158 the corresponding event in these browsers.</p> 159 159 <dl class="docutils"> 160 160 <dt><em>Availability:</em></dt> … … 426 426 <blockquote> 427 427 <ul class="simple"> 428 <li><tt class="docutils literal"><span class="pre">mouse().wheel</span></tt> returns a number for the scroll wheel 429 offset. The number will normally be +3 when scrolling down, 430 and -3 when scrolling up.</li> 428 <li><tt class="docutils literal"><span class="pre">mouse().wheel</span></tt> is a <a class="mochiref reference" href="Style.html#fn-coordinates">MochiKit.Style.Coordinates</a> 429 object containing the scroll wheel offset. The number will be 430 positive when scrolling down (or to the right) and negative 431 when scrolling up (or to the left). Note that only Safari 3 432 currently supports horizontal scrolling. In other browsers, 433 the <tt class="docutils literal"><span class="pre">'y'</span></tt> component will contain the scroll offset for 434 both directions.</li> 431 435 </ul> 432 436 </blockquote> mochikit/trunk/doc/rst/MochiKit/Signal.rst
r1386 r1387 170 170 ``onmousewheel`` 171 171 172 Not strictly synthesized, but named ``'DOMMouseScroll'`` in Firefox173 and Safari browsers. MochiKit translates ``'onmousewheel'`` to the174 correctevent in these browsers.172 Not strictly synthesized, but named ``'DOMMouseScroll'`` in 173 Gecko-based browsers. MochiKit translates ``'onmousewheel'`` to 174 the corresponding event in these browsers. 175 175 176 176 *Availability:* … … 427 427 Properties for ``'onmousewheel'``: 428 428 429 - ``mouse().wheel`` returns a number for the scroll wheel 430 offset. The number will normally be +3 when scrolling down, 431 and -3 when scrolling up. 429 - ``mouse().wheel`` is a :mochiref:`MochiKit.Style.Coordinates` 430 object containing the scroll wheel offset. The number will be 431 positive when scrolling down (or to the right) and negative 432 when scrolling up (or to the left). Note that only Safari 3 433 currently supports horizontal scrolling. In other browsers, 434 the ``'y'`` component will contain the scroll offset for 435 both directions. 432 436 433 437 Known browser bugs: mochikit/trunk/examples/mouse_events/mouse_events.js
r1386 r1387 21 21 22 22 // scrolling up 23 if (event.mouse().wheel < 0) {23 if (event.mouse().wheel.y < 0) { 24 24 // Following test should probably be "if (scrollTop == 0)" which 25 25 // works in FF but not IE. mochikit/trunk/packed/MochiKit/MochiKit.js
r1386 r1387 5036 5036 } 5037 5037 if(this.type()=="mousewheel"){ 5038 m.wheel=e.detail?e.detail:-e.wheelDelta/40; 5038 m.wheel=new MochiKit.Style.Coordinates(0,0); 5039 if(e.wheelDeltaX||e.wheelDeltaY){ 5040 m.wheel.x=e.wheelDeltaX/-40||0; 5041 m.wheel.y=e.wheelDeltaY/-40||0; 5042 }else{ 5043 if(e.wheelDelta){ 5044 m.wheel.y=e.wheelDelta/-40; 5045 }else{ 5046 m.wheel.y=e.detail||0; 5047 } 5048 } 5039 5049 } 5040 5050 this._mouse=m; … … 5148 5158 },_browserAlreadyHasMouseEnterAndLeave:function(){ 5149 5159 return /MSIE/.test(navigator.userAgent); 5150 },_browser HasMouseWheelEvent:function(){5151 return / MSIE/.test(navigator.userAgent)||/Opera/.test(navigator.userAgent);5160 },_browserLacksMouseWheelEvent:function(){ 5161 return /Gecko\//.test(navigator.userAgent); 5152 5162 },_mouseEnterListener:function(src,sig,func,obj){ 5153 5163 var E=MochiKit.Signal.Event; … … 5217 5227 } 5218 5228 }else{ 5219 if(_565&&sig=="onmousewheel"&& !self._browserHasMouseWheelEvent()){5229 if(_565&&sig=="onmousewheel"&&self._browserLacksMouseWheelEvent()){ 5220 5230 var _566=self._listener(src,sig,func,obj,_565); 5221 5231 sig="onDOMMouseScroll"; mochikit/trunk/tests/test_Signal.js
r1386 r1387 113 113 i++; 114 114 t.ok((typeof(e.mouse()) === 'object'), 'checking that mouse() is an object'); 115 t.ok((typeof(e.mouse().wheel) === 'number'), 'checking that mouse().wheel is a number'); 115 t.ok((typeof(e.mouse().wheel) === 'object'), 'checking that mouse().wheel is an object'); 116 t.ok((typeof(e.mouse().wheel.x) === 'number'), 'checking that mouse().wheel.x is a number'); 117 t.ok((typeof(e.mouse().wheel.y) === 'number'), 'checking that mouse().wheel.y is a number'); 116 118 }); 117 119 var nativeSignal = 'mousewheel'; 118 if ( !/MSIE/.test(navigator.userAgent) && !/Opera/.test(navigator.userAgent)) {120 if (MochiKit.Signal._browserLacksMouseWheelEvent()) { 119 121 nativeSignal = 'DOMMouseScroll'; 120 122 }
