@@ -245,24 +245,19 @@ Phaser.Mouse.prototype = {
245245 window . addEventListener ( 'mouseup' , this . _onMouseUpGlobal , true ) ;
246246 this . game . canvas . addEventListener ( 'mouseover' , this . _onMouseOver , true ) ;
247247 this . game . canvas . addEventListener ( 'mouseout' , this . _onMouseOut , true ) ;
248+ }
248249
249- // (These can probably be moved out of the cocoonJS check)
250- // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel
251- if ( 'onwheel' in window || 'WindowEvent' in window )
252- {
253- // DOM3 Wheel Event: FF 17+, IE 9+, Chrome 31+, Safari 7+
254- this . game . canvas . addEventListener ( 'wheel' , this . _onMouseWheel , true ) ;
255- }
256- else if ( 'onmousewheel' in window )
250+ var wheelEvent = this . game . device . wheelEvent ;
251+ if ( wheelEvent )
252+ {
253+ this . game . canvas . addEventListener ( wheelEvent , this . _onMouseWheel , true ) ;
254+
255+ if ( wheelEvent === 'mousewheel' )
257256 {
258- // Non-FF legacy: IE 6-9, Chrome 1-31, Safari 5-7.
259- this . game . canvas . addEventListener ( 'mousewheel' , this . _onMouseWheel , true ) ;
260257 this . _wheelEvent = new WheelEventProxy ( - 1 / 40 , 1 ) ;
261258 }
262- else if ( 'MouseScrollEvent' in window )
259+ else if ( wheelEvent === 'DOMMouseScroll' )
263260 {
264- // FF prior to 17. This should probably be scrubbed.
265- this . game . canvas . addEventListener ( 'DOMMouseScroll' , this . _onMouseWheel , true ) ;
266261 this . _wheelEvent = new WheelEventProxy ( 1 , 1 ) ;
267262 }
268263 }
@@ -563,9 +558,11 @@ Phaser.Mouse.prototype = {
563558 this . game . canvas . removeEventListener ( 'mouseover' , this . _onMouseOver , true ) ;
564559 this . game . canvas . removeEventListener ( 'mouseout' , this . _onMouseOut , true ) ;
565560
566- this . game . canvas . removeEventListener ( 'wheel' , this . _onMouseWheel , true ) ;
567- this . game . canvas . removeEventListener ( 'mousewheel' , this . _onMouseWheel , true ) ;
568- this . game . canvas . removeEventListener ( 'DOMMouseScroll' , this . _onMouseWheel , true ) ;
561+ var wheelEvent = this . game . device . wheelEvent ;
562+ if ( wheelEvent )
563+ {
564+ this . game . canvas . removeEventListener ( wheelEvent , this . _onMouseWheel , true ) ;
565+ }
569566
570567 window . removeEventListener ( 'mouseup' , this . _onMouseUpGlobal , true ) ;
571568
@@ -656,12 +653,12 @@ Object.defineProperties(WheelEventProxy.prototype, {
656653 "deltaMode" : { get : function ( ) { return this . _deltaMode ; } } ,
657654 "deltaY" : {
658655 get : function ( ) {
659- return this . _scaleFactor * ( this . originalEvent . detail || this . originalEvent . wheelDelta || 0 ) ;
656+ return ( this . _scaleFactor * ( this . originalEvent . wheelDelta || this . originalEvent . detail ) ) || 0 ;
660657 }
661658 } ,
662659 "deltaX" : {
663660 get : function ( ) {
664- return this . _scaleFactor * ( this . originalEvent . wheelDeltaX || 0 ) ;
661+ return ( this . _scaleFactor * this . originalEvent . wheelDeltaX ) || 0 ;
665662 }
666663 } ,
667664 "deltaZ" : { value : 0 }
0 commit comments