From: itozyun Date: Sat, 30 Aug 2014 07:04:12 +0000 (+0900) Subject: Version 0.6.71, fix mousewheel & clientSize, & X.Timer.requestFrame. X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=0eaaa84ad608663f26fff366dacc9ab785d2dfe2;p=pettanr%2FclientJs.git Version 0.6.71, fix mousewheel & clientSize, & X.Timer.requestFrame. --- diff --git a/0.6.x/js/00_core/00_X.js b/0.6.x/js/00_core/00_X.js index 2f1e63b..2a9cfe3 100644 --- a/0.6.x/js/00_core/00_X.js +++ b/0.6.x/js/00_core/00_X.js @@ -14,7 +14,7 @@ X.VERSION = '0.6.50'; X.bootTime = + new Date; -X.getTime = new Function( Date.now ? 'return Date.now()' : 'return +new Date' ); +X.getTime = Date.now ? Date.now : new Function( 'return +new Date' ); X.emptyFunction = new Function; diff --git a/0.6.x/js/00_core/05_XTimer.js b/0.6.x/js/00_core/05_XTimer.js index a5873d8..a034a14 100644 --- a/0.6.x/js/00_core/05_XTimer.js +++ b/0.6.x/js/00_core/05_XTimer.js @@ -26,7 +26,6 @@ X.Timer = { endTime : 0, // iOS next : 0, busy : false, // for Opera7 - //frameBusy : false, REQ_FRAME_LIST : [], requestID : 0, @@ -57,7 +56,6 @@ X.Timer = { if( r & X.Callback.UN_LISTEN || c === 1 ){ list.splice( i, 1 ); - //f.kill && f.kill(); continue; } else if( 1 < c ) --q.count; @@ -93,9 +91,9 @@ X.Timer = { var list = X.Timer.REQ_FRAME_LIST, l = list.length, i = 0, q; - //this.frameBusy = true; + time = time || X.getTime(); - console.log( X.getTime() + ' , ' + time ); + // console.log( X.getTime() + ' , ' + time ); for( ; i < l; ++i ){ q = list[ i ]; @@ -105,12 +103,12 @@ X.Timer = { } else { q( time ); }; - //delete f.uid; - //f.kill && f.kill(); }; - //this.frameBusy = false; + list.splice( 0, l ); - if( list.length ) X.Timer.requestID = _enterFrame( X.Timer._onEnterFrame ); + if( list.length ){ + X.Timer.requestID = _enterFrame ? _enterFrame( X.Timer._onEnterFrame ) : X.Timer.add( 0, 1, X.Timer._onEnterFrame ); + }; }, add : function( time, opt_count, args1, args2, args3 ){ @@ -151,10 +149,7 @@ X.Timer = { // fire 中の cancel if( ( q = list[ --i ] ).uid === uid ){ list.splice( i, 1 ); - //f = q.f; - //f.kill && f.kill(); !X.Timer.busy && ( /* q[ INDEX_COUNT ] <= next || */ l === 1 ) && X.Timer._update(); - //q.length = 0; break; }; }; @@ -188,8 +183,6 @@ X.Timer = { // TODO // fire 中の cancel list.splice( i, 1 ); - //delete f.uid; - //f.kill && f.kill(); l === 1 && _cancelFrame( X.Timer.requestID ); break; }; @@ -204,8 +197,6 @@ X.Timer = { if( ( f = list[ --i ] ).uid < uid ) break; if( f.uid === uid ){ list.splice( i, 1 ); - //delete f.uid; - //f.kill && f.kill(); l === 1 && X.Timer.remove( X.Timer.requestID ); break; }; diff --git a/0.6.x/js/01_dom/12_XDomEvent.js b/0.6.x/js/01_dom/12_XDomEvent.js index 7c25930..f479338 100644 --- a/0.6.x/js/01_dom/12_XDomEvent.js +++ b/0.6.x/js/01_dom/12_XDomEvent.js @@ -46,17 +46,23 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ // axis // https://w3g.jp/blog/tools/wheelevent_crossbrowser // ホイール系イベント2014年版クロスブラウザ + if( e.deltaY ){ + this.deltaX = e.deltaX; + this.deltaY = e.deltaY; + } else if( e.wheelDeltaY !== undefined ){ - this.wheelDeltaX = e.wheelDeltaX / 12; - this.wheelDeltaY = e.wheelDeltaY / 12; + this.deltaX = e.wheelDeltaX / 120; + this.deltaY = e.wheelDeltaY / 120; } else if( e.wheelDelta !== undefined ){ - this.wheelDeltaX = this.wheelDeltaY = e.wheelDelta / 12; + this.deltaX = 0; + this.deltaY = e.wheelDelta / 120; } else if( e.detail !== undefined ){ - this.wheelDeltaX = this.wheelDeltaY = - e.detail * 3; + this.deltaX = 0; + this.deltaY = e.type === 'MozMousePixelScroll' ? e.detail / 15 : e.detail; // 3 } else { - this.wheelDeltaX = this.wheelDeltaY = 0; + this.deltaX = this.deltaY = 0; }; if( /* e.constructor === window.TouchEvent || */ e.touches /* for iOS3.13 */ ){ @@ -156,7 +162,8 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ btn & 2 ? 3 : 0; // 左:1(click:0), 中:4, 右:2 }; this.button = this.which - 1; - this.wheelDeltaX = this.wheelDeltaY = e.wheelDelta / 12; + this.deltaX = 0; + this.deltaY = e.wheelDelta / 12; }; }; @@ -197,21 +204,22 @@ X.Dom.Event.Rename = {}; X.Dom.Event.RenameTo = {}; // https://github.com/georgeadamson/jQuery.prefixfree-events/blob/master/jQuery.prefixfree-events.js // https://developer.mozilla.org/en-US/docs/Web/Events/wheel -// - -// DOMMoseScroll -if( X.UA.Gecko && window.MouseScrollEvent ){ - if( 2 <= X.UA.Gecko || ( 1.9 < X.UA.Gecko && 1 <= X.UA.GeckoPatch ) ){ // Gecko 1.9.1+ (firefox3.5+) - console.log( 'wheel <= MozMousePixelScroll' ); - X.Dom.Event.Rename[ 'mousewheel' ] = 'MozMousePixelScroll'; +// +if( document.onwheel === undefined ){ + // DOMMoseScroll + if( X.UA.Gecko && window.MouseScrollEvent ){ + if( 2 <= X.UA.Gecko || ( 1.9 < X.UA.Gecko && 1 <= X.UA.GeckoPatch ) ){ // Gecko 1.9.1+ (firefox3.5+) + console.log( 'wheel <= MozMousePixelScroll' ); + X.Dom.Event.Rename[ 'wheel' ] = 'MozMousePixelScroll'; + } else + if( 0.9 < X.UA.Gecko && 7 <= X.UA.GeckoPatch ){ // Gecko 0.9.7+ (NN6.2+?) + console.log( 'wheel <= DOMMouseScroll' ); + X.Dom.Event.Rename[ 'wheel' ] = 'DOMMouseScroll'; + }; } else - if( 0.9 < X.UA.Gecko && 7 <= X.UA.GeckoPatch ){ // Gecko 0.9.7+ (NN6.2+?) - console.log( 'wheel <= DOMMouseScroll' ); - X.Dom.Event.Rename[ 'wheel' ] = 'DOMMouseScroll'; - }; -} else -if( document.onmousewheel !== undefined ){ - X.Dom.Event.Rename[ 'wheel' ] = 'mousewheel'; + if( document.onmousewheel !== undefined ){ + X.Dom.Event.Rename[ 'wheel' ] = 'mousewheel'; + }; }; if( window.onwebkitanimationend !== undefined && window.onanimationend === undefined ){ diff --git a/0.6.x/js/01_dom/13_XDomBoxModel.js b/0.6.x/js/01_dom/13_XDomBoxModel.js index 855a9b5..c3c0bf5 100644 --- a/0.6.x/js/01_dom/13_XDomBoxModel.js +++ b/0.6.x/js/01_dom/13_XDomBoxModel.js @@ -121,6 +121,50 @@ Node.prototype.height = function(){ }; }; +Node.prototype.clientWidth = function(){ + if( !this.parent ){// todo : _state で tree に所属しているか?判定 + console.log( 'xnode.width() : no parent' ); + return 0; + }; + Node._body._updateTimerID && Node._body._startUpdate(); + if( !this._root ){ + console.log( 'xnode.width() : not belong tree.' ); + return 0; + }; + if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( X.Dom.DOM_W3C ){ + // this.css( X.Dom.Style.Unit.px, 'width' ); + return this._rawNode.clientWidth; + } else + if( X.Dom.DOM_IE4 ){ + return ( this._rawNode || this._ie4getRawNode() ).clientWidth; + } else { + + }; +}; + +Node.prototype.clientHeight = function(){ + if( !this.parent ){ + console.log( 'xnode.height() : no parent' ); + return 0; + }; + Node._body._updateTimerID && Node._body._startUpdate(); + if( !this._root ){ + console.log( 'xnode.height() : not belong tree.' ); + return 0; + }; + if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( X.Dom.DOM_W3C ){ + // this.css( X.Dom.Style.Unit.px, 'height' ); + return this._rawNode.clientHeight; + } else + if( X.Dom.DOM_IE4 ){ + return ( this._rawNode || this._ie4getRawNode() ).clientHeight; + } else { + + }; +}; + Node.prototype.scrollWidth = function(){ if( !this.parent ){// todo : _state で tree に所属しているか?判定 console.log( 'xnode.width() : no parent' ); diff --git a/0.6.x/js/01_dom/15_XDomStyle.js b/0.6.x/js/01_dom/15_XDomStyle.js index 4977e24..34852d5 100644 --- a/0.6.x/js/01_dom/15_XDomStyle.js +++ b/0.6.x/js/01_dom/15_XDomStyle.js @@ -1188,39 +1188,35 @@ X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, function(){ X.Dom.Style.VENDER_PREFIX = (function(){ var ret = {}, vendors = 'webkit,Webkit,Moz,moz,ms,Ms,O,o,khtml,Khtml'.split( ',' ), - searches = + searches = ( 'opacity,boxSizing,' + 'transform,transformOrigin,perspective,' + 'transisiton,transitionDelay,transitionProperty,transitionDuration,transitionTimingFunction,' + - 'userSelect,touchAction,touchCallout,contentZooming,userDrag,tapHighlightColor'.split( ',' ), - vendor, i, search, prop; - // - vendors.unshift( '' ); - - function findVenderPrefix( prop ){ - var v, i = vendors.length; - vendor = null; - for( ; i; ){ - v = vendors[ --i ]; - if( testStyle[ v + prop ] !== undefined ){ - vendor = v; - return v + prop; - }; - }; - }; - + 'userSelect,touchAction,touchCallout,contentZooming,userDrag,tapHighlightColor' ).split( ',' ), + vendor, i, search, prop, j, v; + for( i = searches.length; i; ){ - search = searches[ --i ]; - prop = findVenderPrefix( search ); - if( search === 'transform' ) ret.transVender = vendor; - if( prop ) ret[ search ] = prop; + search = prop = searches[ --i ]; + + if( testStyle[ prop ] === undefined ){ + prop = prop.charAt( 0 ).toUpperCase() + prop.substr( 1 ); + for( j = vendors.length; j; ){ + v = vendors[ --j ]; + if( testStyle[ v + prop ] !== undefined ){ + ret[ search ] = v + prop; + break; + }; + }; + } else { + ret[ search ] = prop; + }; }; return ret; })(); X.Dom.Style.SPECIAL_FIX_PROP = // ~IE8 - X.UA.IE && X.UA.IE < 9 && !X.UA.MacIE ? + X.UA.IE < 9 && !X.UA.MacIE ? { filter : 1, opacity : 2//, uinode ChromeNode で行う @@ -1229,7 +1225,7 @@ X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, function(){ //backgroundImage : 5 } : // IE9 - X.UA.IE && 9 <= X.UA.IE && X.UA.IE < 10 ? + 9 <= X.UA.IE && X.UA.IE < 10 ? { filter : 1//, //textShadow : 1