// axis\r
// https://w3g.jp/blog/tools/wheelevent_crossbrowser\r
// ホイール系イベント2014年版クロスブラウザ\r
- if( e.deltaY ){\r
- this.deltaX = e.deltaX;\r
- this.deltaY = e.deltaY;\r
+ if( e.deltaY !== undefined ){\r
+ this.deltaX = e.deltaX / 100;\r
+ this.deltaY = e.deltaY / 100;\r
} else\r
if( e.wheelDeltaY !== undefined ){\r
this.deltaX = e.wheelDeltaX / 120;\r
} else\r
if( e.wheelDelta !== undefined ){\r
this.deltaX = 0;\r
- this.deltaY = -e.wheelDelta / 120;\r
+ this.deltaY = e.wheelDelta / -120;\r
} else\r
if( e.detail !== undefined ){\r
this.deltaX = 0;\r
- this.deltaY = e.type === 'MozMousePixelScroll' ? e.detail / 15 : e.detail; // 3\r
+ this.deltaY = e.type === 'MozMousePixelScroll' ? e.detail / 45 : e.detail / 3; // 3\r
} else {\r
this.deltaX = this.deltaY = 0;\r
};\r
};\r
this.button = this.which - 1;\r
this.deltaX = 0;\r
- this.deltaY = e.wheelDelta / -12;\r
+ this.deltaY = e.wheelDelta / -120;\r
\r
if( this.type === 'wheel' ) console.log( e.wheelDelta );\r
};\r
console.log( 'wheel <= DOMMouseScroll' );\r
X.Dom.Event.Rename[ 'wheel' ] = 'DOMMouseScroll';\r
};\r
- } else\r
- if( document.onmousewheel !== undefined ){\r
+ } else {\r
+ X.Dom.Event.Rename[ 'wheel' ] = 'mousewheel';\r
+ };\r
+ if( document.onmousewheel !== undefined ){ // Opera で判定失敗\r
X.Dom.Event.Rename[ 'wheel' ] = 'mousewheel';\r
- }; \r
+ };\r
};\r
\r
+\r
+\r
if( window.onwebkitanimationend !== undefined && window.onanimationend === undefined ){\r
console.log( 'animationend <= webkitAnimationEnd' );\r
X.Dom.Event.Rename[ 'animationend' ] = 'webkitAnimationEnd';\r
\r
\r
\r
-X.Dom.Node.prototype.listen = function( type, arg1, arg2, arg3 /* [ listener || ( context + function ) || function ][ arguments ] */ ){\r
- if( this._xnodeType === 0 || this._xnodeType === 3 ) return this;\r
- \r
- if( X.Type.isArray( type ) ){\r
- return X.EventDispatcher.prototype.listen.apply( this, arguments );\r
- };\r
- \r
- ( !this._listeners || !this._listeners[ type ] ) && X.Type.isString( type ) && this._addEvent( type );\r
- \r
- return X.EventDispatcher.prototype.listen.apply( this, arguments );\r
-};\r
-\r
-X.Dom.Node.prototype._addEvent =\r
- // Days on the Moon DOM Events とブラウザの実装 \r
- // http://nanto.asablo.jp/blog/2007/03/23/1339502\r
- // Safari 2 では関数オブジェクトしか EventListener として使えませんが、Safari のナイトリービルドでは handleEvent メソッドを持つオブジェクトも EventListener として使えるようです。\r
- X.Dom.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3-\r
- (function( type ){\r
- var raw = this._rawNode;\r
- if( !raw ) return;\r
- this._handleEvent = this._handleEvent || X.Callback.create( this );\r
- type = X.Dom.Event.Rename[ type ] || type;\r
- if( raw.addEventListener ){\r
- raw.addEventListener( type, this._handleEvent, false );\r
- } else {\r
- // Safari は Image, Opera7 は window\r
- raw[ 'on' + type ] = this._handleEvent;\r
- };\r
- }) :\r
- X.Dom.EVENT_W3C ?\r
- (function( type ){\r
- this._rawNode && this._rawNode.addEventListener( X.Dom.Event.Rename[ type ] || type, this, false );\r
- }) :\r
- X.Dom.EVENT_IE ?\r
- (function( type ){\r
- var raw = this._rawNode;\r
- if( !raw ) return;\r
- type = X.Dom.Event.Rename[ type ] || type;\r
- //if( type === 'load' && this._tag && X.Dom.Event._LOAD_FIX_TAGS[ this._tag ] ){\r
- // type = 'readystatechange';\r
- //};\r
- this._handleEvent = this._handleEvent || X.Callback.create( this );\r
- if( raw.attachEvent ){\r
- raw.attachEvent( 'on' + type, this._handleEvent );\r
- } else {\r
- raw[ 'on' + type ] = this._handleEvent;\r
- };\r
- }) :\r
- (function( type ){\r
- var raw = this._rawNode || ( this._ie4getRawNode && this._ie4getRawNode() );\r
- if( !raw ) return;\r
- raw[ 'on' + ( X.Dom.Event.Rename[ type ] || type ) ] = this._handleEvent = this._handleEvent || X.Callback.create( this );\r
- });\r
-\r
-\r
-X.Dom.Node.prototype.unlisten = function( type, arg1, arg2, arg3 ){\r
- var list = this._listeners, l;\r
- \r
- if( X.Type.isArray( type ) ){\r
- return list ? X.EventDispatcher.prototype.unlisten.apply( this, arguments ) : this;\r
- };\r
-\r
- l = !this._dispatching && list && type !== undefined && list[ type ] && list[ type ].length;\r
- \r
- X.EventDispatcher.prototype.unlisten.apply( this, arguments );\r
- \r
- l && !list[ type ] && X.Type.isString( type ) && this._removeEvent( type );\r
- \r
- return this;\r
-};\r
-\r
-X.Dom.Node.prototype._removeEvent =\r
- X.Dom.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3-\r
- (function( type ){\r
- var raw = this._rawNode;\r
- if( !raw ) return;\r
- type = X.Dom.Event.Rename[ type ] || type;\r
- \r
- if( raw.addEventListener ){ // Image\r
- raw.removeEventListener( type, this._handleEvent, false );\r
- } else {\r
- raw[ 'on' + type ] = null;\r
- };\r
- if( !this._listeners ){\r
- X.Callback._correct( this._handleEvent );\r
- delete this._handleEvent;\r
- };\r
- }) :\r
- X.Dom.EVENT_W3C ?\r
- (function( type ){\r
- var raw = this._rawNode;\r
- if( !raw ) return;\r
- raw.removeEventListener( X.Dom.Event.Rename[ type ] || type, this, false );\r
- }) :\r
- X.Dom.EVENT_IE ?\r
- (function( type ){\r
- var raw = this._rawNode;\r
- if( !raw ) return;\r
- type = X.Dom.Event.Rename[ type ] || type;\r
- //if( type === 'load' && this._tag && X.Dom.Event._LOAD_FIX_TAGS[ this._tag ] ){\r
- // type = 'readystatechange';\r
- //};\r
- if( raw.attachEvent ){\r
- raw.detachEvent( 'on' + type, this._handleEvent );\r
- } else {\r
- raw[ 'on' + type ] = X.emptyFunction;\r
- raw[ 'on' + type ] = '';\r
- };\r
- if( !this._listeners ){\r
- X.Callback._correct( this._handleEvent );\r
- delete this._handleEvent;\r
- };\r
- }) :\r
- (function( type ){\r
- var raw = this._rawNode || ( this._ie4getRawNode && this._ie4getRawNode() );\r
- if( !raw ) return;\r
- type = X.Dom.Event.Rename[ type ] || type;\r
- raw[ 'on' + type ] = X.emptyFunction;\r
- raw[ 'on' + type ] = '';\r
- if( !this._listeners ){\r
- X.Callback._correct( this._handleEvent );\r
- delete this._handleEvent;\r
- };\r
- });\r
-\r
+// TODO handleEvent を拡張可能にするために、クロージャに移動する\r
// Is this in regard to the Safari 1.x preventDefault bug on click/dblclick?\r
// https://groups.google.com/forum/#!msg/comp.lang.javascript/uYEuCHjHxnw/yKoHtZJPa1QJ\r
X.Dom.Node.prototype.handleEvent =\r
if( !hash ) return;\r
for( type in hash ){\r
// 数字イベントの除外\r
- /*'' + parseFloat( type ) !== type && */this._removeEvent( type );\r
+ /*'' + parseFloat( type ) !== type && */x_eventdispatcher_actualRemoveEvent( this, type );\r
};\r
};\r
\r
if( !hash ) return;\r
for( type in hash ){\r
// 数字イベントの除外\r
- /*'' + parseFloat( type ) !== type && */ this._addEvent( type );\r
+ /*'' + parseFloat( type ) !== type && */ x_eventdispatcher_actualAddEvent( this, type );\r
};\r
};\r
\r