OSDN Git Service

Version 0.6.71, fix mousewheel & clientSize, & X.Timer.requestFrame.
authoritozyun <itozyun@user.sourceforge.jp>
Sat, 30 Aug 2014 07:04:12 +0000 (16:04 +0900)
committeritozyun <itozyun@user.sourceforge.jp>
Sat, 30 Aug 2014 07:04:12 +0000 (16:04 +0900)
0.6.x/js/00_core/00_X.js
0.6.x/js/00_core/05_XTimer.js
0.6.x/js/01_dom/12_XDomEvent.js
0.6.x/js/01_dom/13_XDomBoxModel.js
0.6.x/js/01_dom/15_XDomStyle.js

index 2f1e63b..2a9cfe3 100644 (file)
@@ -14,7 +14,7 @@ X.VERSION = '0.6.50';
                \r
 X.bootTime = + new Date;\r
                \r
-X.getTime = new Function( Date.now ? 'return Date.now()' : 'return +new Date' );\r
+X.getTime = Date.now ? Date.now : new Function( 'return +new Date' );\r
 \r
 \r
 X.emptyFunction = new Function;\r
index a5873d8..a034a14 100644 (file)
@@ -26,7 +26,6 @@ X.Timer = {
        endTime        : 0, // iOS\r
        next           : 0,\r
        busy           : false, // for Opera7\r
-       //frameBusy      : false,\r
        \r
        REQ_FRAME_LIST : [],\r
        requestID      : 0,\r
@@ -57,7 +56,6 @@ X.Timer = {
                        \r
                        if( r & X.Callback.UN_LISTEN || c === 1 ){\r
                                list.splice( i, 1 );\r
-                               //f.kill && f.kill();\r
                                continue;\r
                        } else\r
                        if( 1 < c ) --q.count;\r
@@ -93,9 +91,9 @@ X.Timer = {
                var list = X.Timer.REQ_FRAME_LIST,\r
                        l    = list.length,\r
                        i    = 0, q;\r
-               //this.frameBusy = true;\r
+\r
                time = time || X.getTime();\r
-               console.log( X.getTime() + ' , ' + time );\r
+               // console.log( X.getTime() + ' , ' + time );\r
            for( ; i < l; ++i ){\r
                q = list[ i ];\r
                \r
@@ -105,12 +103,12 @@ X.Timer = {
                        } else {\r
                                q( time );\r
                        };\r
-               //delete f.uid;\r
-               //f.kill && f.kill();\r
            };\r
-           //this.frameBusy = false;\r
+\r
            list.splice( 0, l );\r
-           if( list.length ) X.Timer.requestID = _enterFrame( X.Timer._onEnterFrame );\r
+           if( list.length ){\r
+               X.Timer.requestID = _enterFrame ? _enterFrame( X.Timer._onEnterFrame ) : X.Timer.add( 0, 1, X.Timer._onEnterFrame );\r
+           };\r
        },\r
        \r
        add : function( time, opt_count, args1, args2, args3 ){\r
@@ -151,10 +149,7 @@ X.Timer = {
                        // fire 中の cancel\r
                        if( ( q = list[ --i ] ).uid === uid ){\r
                                list.splice( i, 1 );\r
-                               //f = q.f;\r
-                               //f.kill && f.kill();\r
                                !X.Timer.busy && ( /* q[ INDEX_COUNT ] <= next  || */ l === 1 ) && X.Timer._update();\r
-                               //q.length = 0;\r
                                break;\r
                        };\r
                };\r
@@ -188,8 +183,6 @@ X.Timer = {
                                        // TODO\r
                                        // fire 中の cancel\r
                                        list.splice( i, 1 );\r
-                                       //delete f.uid;\r
-                                       //f.kill && f.kill();\r
                                        l === 1 && _cancelFrame( X.Timer.requestID );\r
                                        break;\r
                                };\r
@@ -204,8 +197,6 @@ X.Timer = {
                                if( ( f = list[ --i ] ).uid < uid ) break;\r
                                if( f.uid === uid ){\r
                                        list.splice( i, 1 );\r
-                                       //delete f.uid;\r
-                                       //f.kill && f.kill();\r
                                        l === 1 && X.Timer.remove( X.Timer.requestID );\r
                                        break;\r
                                };\r
index 7c25930..f479338 100644 (file)
@@ -46,17 +46,23 @@ if( !X.UA.IE || 9 <= X.UA.IE ){
                // 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
+               } else\r
                if( e.wheelDeltaY !== undefined ){\r
-                       this.wheelDeltaX = e.wheelDeltaX / 12;\r
-                       this.wheelDeltaY = e.wheelDeltaY / 12;\r
+                       this.deltaX = e.wheelDeltaX / 120;\r
+                       this.deltaY = e.wheelDeltaY / 120;\r
                } else\r
                if( e.wheelDelta !== undefined ){\r
-                       this.wheelDeltaX = this.wheelDeltaY = e.wheelDelta / 12;\r
+                       this.deltaX = 0;\r
+                       this.deltaY = e.wheelDelta / 120;\r
                } else\r
                if( e.detail !== undefined ){\r
-                       this.wheelDeltaX = this.wheelDeltaY = - e.detail * 3;\r
+                       this.deltaX = 0;\r
+                       this.deltaY = e.type === 'MozMousePixelScroll' ? e.detail / 15 : e.detail; // 3\r
                } else {\r
-                       this.wheelDeltaX = this.wheelDeltaY = 0;\r
+                       this.deltaX = this.deltaY = 0;\r
                };\r
                \r
                if( /* e.constructor === window.TouchEvent || */ e.touches /* for iOS3.13 */ ){\r
@@ -156,7 +162,8 @@ if( !X.UA.IE || 9 <= X.UA.IE ){
                                        btn & 2 ? 3 : 0; // 左:1(click:0), 中:4, 右:2\r
                };\r
                this.button      = this.which - 1;\r
-               this.wheelDeltaX = this.wheelDeltaY = e.wheelDelta / 12;\r
+               this.deltaX      = 0;\r
+               this.deltaY      = e.wheelDelta / 12;\r
        };\r
 };\r
 \r
@@ -197,21 +204,22 @@ X.Dom.Event.Rename = {};
 X.Dom.Event.RenameTo = {};\r
 // https://github.com/georgeadamson/jQuery.prefixfree-events/blob/master/jQuery.prefixfree-events.js\r
 // https://developer.mozilla.org/en-US/docs/Web/Events/wheel\r
-// \r
-\r
-// DOMMoseScroll\r
-if( X.UA.Gecko && window.MouseScrollEvent ){\r
-       if( 2 <= X.UA.Gecko || ( 1.9 < X.UA.Gecko && 1 <= X.UA.GeckoPatch ) ){ // Gecko 1.9.1+ (firefox3.5+)\r
-               console.log( 'wheel <= MozMousePixelScroll' );\r
-               X.Dom.Event.Rename[ 'mousewheel' ] = 'MozMousePixelScroll';\r
+//\r
+if( document.onwheel === undefined ){\r
+       // DOMMoseScroll\r
+       if( X.UA.Gecko && window.MouseScrollEvent ){\r
+               if( 2 <= X.UA.Gecko || ( 1.9 < X.UA.Gecko && 1 <= X.UA.GeckoPatch ) ){ // Gecko 1.9.1+ (firefox3.5+)\r
+                       console.log( 'wheel <= MozMousePixelScroll' );\r
+                       X.Dom.Event.Rename[ 'wheel' ] = 'MozMousePixelScroll';\r
+               } else\r
+               if( 0.9 < X.UA.Gecko && 7 <= X.UA.GeckoPatch ){ // Gecko 0.9.7+ (NN6.2+?)\r
+                       console.log( 'wheel <= DOMMouseScroll' );\r
+                       X.Dom.Event.Rename[ 'wheel' ] = 'DOMMouseScroll';\r
+               };\r
        } else\r
-       if( 0.9 < X.UA.Gecko && 7 <= X.UA.GeckoPatch ){ // Gecko 0.9.7+ (NN6.2+?)\r
-               console.log( 'wheel <= DOMMouseScroll' );\r
-               X.Dom.Event.Rename[ 'wheel' ] = 'DOMMouseScroll';\r
-       };\r
-} else\r
-if( document.onmousewheel !== undefined ){\r
-       X.Dom.Event.Rename[ 'wheel' ] = 'mousewheel';\r
+       if( document.onmousewheel !== undefined ){\r
+               X.Dom.Event.Rename[ 'wheel' ] = 'mousewheel';\r
+       };      \r
 };\r
 \r
 if( window.onwebkitanimationend !== undefined && window.onanimationend === undefined ){\r
index 855a9b5..c3c0bf5 100644 (file)
@@ -121,6 +121,50 @@ Node.prototype.height = function(){
        };\r
 };\r
 \r
+Node.prototype.clientWidth = function(){\r
+       if( !this.parent ){// todo : _state で tree に所属しているか?判定\r
+               console.log( 'xnode.width() : no parent' );\r
+               return 0;\r
+       };\r
+       Node._body._updateTimerID && Node._body._startUpdate();\r
+       if( !this._root ){\r
+               console.log( 'xnode.width() : not belong tree.' );\r
+               return 0;\r
+       };\r
+       if( this._state & X.Dom.State.DISPLAY_NONE ) return 0;\r
+       if( X.Dom.DOM_W3C ){\r
+               // this.css( X.Dom.Style.Unit.px, 'width' );\r
+               return this._rawNode.clientWidth;\r
+       } else\r
+       if( X.Dom.DOM_IE4 ){\r
+               return ( this._rawNode || this._ie4getRawNode() ).clientWidth;\r
+       } else {\r
+               \r
+       };\r
+};\r
+\r
+Node.prototype.clientHeight = function(){\r
+       if( !this.parent ){\r
+               console.log( 'xnode.height() : no parent' );\r
+               return 0;\r
+       };\r
+       Node._body._updateTimerID && Node._body._startUpdate();\r
+       if( !this._root ){\r
+               console.log( 'xnode.height() : not belong tree.' );\r
+               return 0;\r
+       };\r
+       if( this._state & X.Dom.State.DISPLAY_NONE ) return 0;\r
+       if( X.Dom.DOM_W3C ){\r
+               // this.css( X.Dom.Style.Unit.px, 'height' );\r
+               return this._rawNode.clientHeight;\r
+       } else\r
+       if( X.Dom.DOM_IE4 ){\r
+               return ( this._rawNode || this._ie4getRawNode() ).clientHeight;\r
+       } else {\r
+               \r
+       };\r
+};\r
+\r
 Node.prototype.scrollWidth = function(){\r
        if( !this.parent ){// todo : _state で tree に所属しているか?判定\r
                console.log( 'xnode.width() : no parent' );\r
index 4977e24..34852d5 100644 (file)
@@ -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