X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_dom%2F12_XDomEvent.js;h=fd81b0162fc1ef1248fcea6c18de452c0f917531;hb=78285fe0ef4d01314fd05c96490f435fa8221eaf;hp=591c479df5f44ee1e988b4668100a5a1f612682a;hpb=08e72a61fa7363b2fb04f5bc863df082c3067e47;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/01_dom/12_XDomEvent.js b/0.6.x/js/01_dom/12_XDomEvent.js index 591c479..fd81b01 100644 --- a/0.6.x/js/01_dom/12_XDomEvent.js +++ b/0.6.x/js/01_dom/12_XDomEvent.js @@ -2,6 +2,7 @@ * use X.Callback * * http://d.hatena.ne.jp/uupaa/20100430/1272561922 + * event.offsetX と offsetY の互換性について * */ @@ -28,8 +29,8 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ //this.screenY = e.screenY; this.pageX = e.pageX; this.pageY = e.pageY; - this.offsetX = e.offsetX || e.layerX; - this.offsetY = e.offsetY || e.layerY; + this.offsetX = e.offsetX || e.layerX || 0; // 要素上の座標を取得 + this.offsetY = e.offsetY || e.layerY || 0; this.keyCode = e.keyCode; this.altKey = e.altKey; @@ -47,8 +48,8 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ // https://w3g.jp/blog/tools/wheelevent_crossbrowser // ホイール系イベント2014年版クロスブラウザ if( e.deltaY !== undefined ){ - this.deltaX = e.deltaX / 100; - this.deltaY = e.deltaY / 100; + this.deltaX = e.deltaX; + this.deltaY = e.deltaY; } else if( e.wheelDeltaY !== undefined ){ this.deltaX = e.wheelDeltaX / 120; @@ -103,11 +104,11 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ window.PointerEvent = window.MSPointerEvent; }; } else { - X.Dom.Event = function( e, xnode, element ){ + X.Dom.Event = function( e, xnode, element, opt_type ){ var btn; //this._event = e; - this.type = X.Dom.Event.RenameTo[ e.type ] || e.type; + this.type = X.Dom.Event.RenameTo[ e.type ] || e.type || opt_type; this.target = Node._getXNode( e.srcElement ); // xnode if( this.target && this.target._xnodeType === 3 ) this.target = this.target.parent; // ie4 の fake Textnode がヒットしていないか? this.currentTarget = xnode; // xnode @@ -291,71 +292,6 @@ if( navigator.msPointerEnabled && !navigator.pointerEnabled ){ })( X.Dom.Event.Rename, X.Dom.Event.RenameTo ); - -// TODO handleEvent を拡張可能にするために、クロージャに移動する -// Is this in regard to the Safari 1.x preventDefault bug on click/dblclick? -// https://groups.google.com/forum/#!msg/comp.lang.javascript/uYEuCHjHxnw/yKoHtZJPa1QJ -X.Dom.Node.prototype.handleEvent = - X.UA.IE4 || X.UA.IE5678 ? // ie45678 EVENT_IE & EVENT_DOM0 for ie4 - (function(){ - var ret; - - if( event.type === 'readystatechange' && this._tag && X.Dom.Event._LOAD_FIX_TAGS[ this._tag ] ){ - //type = 'readystatechange'; - }; - - ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( event, this, this._rawNode ) ); - - if( ret & X.Callback.STOP_PROPAGATION ){ - event.cancelBubble = true; - }; - if( ret & X.Callback.PREVENT_DEFAULT ){ - this._tag === 'A' && this._rawNode.blur(); - return event.returnValue = false; - }; - }) : - //X.Dom.EVENT_W3C & EVENT_DOM0 - (function( e ){ - var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( e, this ) ); - - if( ret & X.Callback.STOP_PROPAGATION ){ - e.stopPropagation(); - }; - if( ret & X.Callback.PREVENT_DEFAULT ){ - this._tag === 'A' && this._rawNode.blur(); - e.preventDefault(); - if( X.UA.WebKit < 525.13 ){ // Safari3- - if( e.type === 'click' || e.type === 'dbclick' ){ - X.Dom._safariPreventDefault = true; - }; - }; - return false; - }; - }); - - -// イベントの退避、dom が画面から抜かれる場合に実施しておく -X.Dom.Node.prototype._migrateEvent = function(){ - var hash = this._listeners, - type; - if( !hash ) return; - for( type in hash ){ - // 数字イベントの除外 - /*'' + parseFloat( type ) !== type && */x_eventdispatcher_actualRemoveEvent( this, type ); - }; -}; - -// 退避したイベントの復帰 -X.Dom.Node.prototype._restoreEvent = function(){ - var hash = this._listeners, - type; - if( !hash ) return; - for( type in hash ){ - // 数字イベントの除外 - /*'' + parseFloat( type ) !== type && */ x_eventdispatcher_actualAddEvent( this, type ); - }; -}; - /* ----------------------------------------------- * Document Ready * Dean Edwards/Matthias Miller/John Resig @@ -400,16 +336,5 @@ X.Dom.listenOnce( X.Dom.Event.XDOM_READY, function(e){ console.log( 'X.Dom XDomReady ' + X.Dom.readyState ); } ); -if( X.UA.WebKit < 525.13 ){ // Safari3- - document.documentElement.onclick = - document.documentElement.ondbclick = function( e ){ - if( X.Dom._safariPreventDefault ){ - X.Dom._safariPreventDefault = false; - e.preventDefault(); - return false; - }; - }; -}; - -X.Dom.listen( X.Dom.Event.VIEW_RESIZED, function(e){ console.log( 'X.Dom VIEW_RESIZED ' + e.w + 'x' + e.h ); } ); +X.Dom.listen( X.Dom.Event.VIEW_RESIZED, function(e){ console.log( 'X.Dom VIEW_RESIZED ' + e.w + ' x ' + e.h ); } );