X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_dom%2F13_XDomBoxModel.js;fp=0.6.x%2Fjs%2F01_dom%2F13_XDomBoxModel.js;h=9076194611825fc4d29b854246922ed4c29762c6;hb=2846c98310b046f554616440ea8fcbbe9575a7a0;hp=c3c0bf556e73af573ae885c55004900988f411a4;hpb=cdafe7cc99a627ea1b1b17efb6c84b595c1543ec;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/01_dom/13_XDomBoxModel.js b/0.6.x/js/01_dom/13_XDomBoxModel.js index c3c0bf5..9076194 100644 --- a/0.6.x/js/01_dom/13_XDomBoxModel.js +++ b/0.6.x/js/01_dom/13_XDomBoxModel.js @@ -307,3 +307,37 @@ Node.prototype.y = function(){ }; }; +Node.prototype.offset = function( /* xnodeParent */ ){ + var x = 0, y = 0, elm; + + if( !this.parent ){ + console.log( 'xnode.offset() : no parent' ); + return { x : 0, y : 0 }; + }; + Node._body._updateTimerID && Node._body._startUpdate(); + if( !this._root ){ + console.log( 'xnode.offset() : not belong tree.' ); + return { x : 0, y : 0 }; + }; + if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + + if( X.Dom.Node._body === this || X.Dom.Node._html === this ){ + return { x : 0, y : 0 }; + }; + + if( X.Dom.DOM_W3C ){ + elm = this._rawNode; + } else + if( X.Dom.DOM_IE4 ){ + elm = this._rawNode || this._ie4getRawNode(); + } else { + + }; + + while( elm && elm !== document.body ){ + x += elm.offsetLeft; + y += elm.offsetTop; + elm = elm.offsetParent || elm.parentNode || elm.parentElement; + }; + return { x : x, y : y }; +};