リビジョン | 9f1658e2858d8eed1c3933184aa7858596015b61 (tree) |
---|---|
日時 | 2014-08-19 22:43:15 |
作者 | itozyun <itozyun@user...> |
コミッター | itozyun |
Version 0.6.64, fixed X.Callback & function-hash, working Touch & Pointer Event.
@@ -79,7 +79,6 @@ html, body { | ||
79 | 79 | .ActiveX-enabled .mouse-operation-catcher { |
80 | 80 | background-color : #fff; |
81 | 81 | filter : alpha( opacity=0 ); |
82 | - -ms-filter : alpha( opacity=0 ); | |
83 | 82 | } |
84 | 83 | /* |
85 | 84 | * ie では、背景を設定しないと、 mousemove が働かない。 |
@@ -99,7 +98,7 @@ html, body { | ||
99 | 98 | left : 0; |
100 | 99 | top : 0; |
101 | 100 | visibility : hidden; |
102 | - z-index : 99; | |
101 | + /*z-index : 99;*/ | |
103 | 102 | } |
104 | 103 | |
105 | 104 | /* Scrollbox |
@@ -10,9 +10,12 @@ X.UA = (function( n, undefined ){ | ||
10 | 10 | i, j, v; |
11 | 11 | |
12 | 12 | console.log( ' userAgent : ' + dua ); |
13 | + console.log( '-' ); | |
13 | 14 | console.log( ' appVersion : ' + dav ); |
15 | + console.log( '-' ); | |
14 | 16 | console.log( ' platform : ' + n.platform ); |
15 | - | |
17 | + console.log( '-' ); | |
18 | + | |
16 | 19 | if( window.opera ){ |
17 | 20 | i = dua.indexOf( 'Opera' ); // Opera/ |
18 | 21 | j = dua.indexOf( 'Version/' ); |
@@ -125,6 +128,8 @@ X.UA = (function( n, undefined ){ | ||
125 | 128 | acme.WebKit = i = parseFloat(dua.split("WebKit\/")[1]) || undefined; |
126 | 129 | acme.Chrome = parseFloat(dua.split("Chrome\/")[1]) || undefined; |
127 | 130 | |
131 | + console.log( '>>Webkit : ' + acme.WebKit ); | |
132 | + | |
128 | 133 | if( i && !acme.Chrome && dua.indexOf( 'Safari' ) !== -1 ){ |
129 | 134 | if( dav.indexOf( 'Version/' ) !== -1 ){ |
130 | 135 | acme.Safari = parseFloat( dav.split("Version/")[1] ); |
@@ -164,7 +169,7 @@ X.UA = (function( n, undefined ){ | ||
164 | 169 | |
165 | 170 | // Mozilla/5.0 (Android; Linux armv7l; rv:9.0) Gecko/20111216 Firefox/9.0 Fennec/9.0 |
166 | 171 | if( ( i = dua.toLowerCase().indexOf( 'android' ) ) !== -1 ){ |
167 | - acme.Android = parseFloat( ua.substr( i + 8 ) ) || 1.5; | |
172 | + acme.Android = parseFloat( dua.substr( i + 8 ) ) || 1.5; | |
168 | 173 | console.log( '>> Android : ' + acme.Android ); |
169 | 174 | } else |
170 | 175 | if( dua.indexOf( 'iPhone;' ) !== -1 || dua.indexOf( 'iPad;' ) !== -1 || dua.indexOf( 'iPod;' ) !== -1 ){ |
@@ -10,168 +10,182 @@ X.Callback = { | ||
10 | 10 | MONOPOLY : 16, // move event を独占する |
11 | 11 | SYS_CANCEL : 32 | 4 | 2, |
12 | 12 | |
13 | + _USE_CLOSURE : false, | |
14 | + | |
13 | 15 | _LIVE_LIST : [], |
14 | 16 | _POOL_LIST : [], |
15 | 17 | |
18 | + _THIS_FUNC : 1, | |
19 | + _HANDLEEVENT : 2, | |
20 | + _FUNC_ONLY : 3, | |
21 | + | |
16 | 22 | create : function( arg0, arg1, arg2 /* [ listener || ( context + function ) || function ][ args... ] */ ){ |
17 | - var self = X.Callback, | |
18 | - live = self._LIVE_LIST, | |
19 | - f, listener, context, callback; | |
23 | + var live = X.Callback._LIVE_LIST, | |
24 | + hash = X.Callback._checkCallbackArgs( arg0, arg1, arg2 ), | |
25 | + f; | |
20 | 26 | |
21 | - if( typeof arg1 === 'function' ){ | |
22 | - context = arg0; | |
23 | - callback = arg1; | |
24 | - } else | |
25 | - if( typeof arg0 === 'function' ){ | |
26 | - callback = arg0; | |
27 | - if( !( arg2 = arg1 ) ) return callback; // function のみの場合 callback オブジェクトを作らない | |
28 | - } else | |
29 | - if( arg0 && typeof arg0.handleEvent === 'function' ){ | |
30 | - listener = arg0; | |
31 | - arg2 = arg1; | |
32 | - } else { | |
33 | - var v = ''; | |
34 | - for( var k in arg0 ){ | |
35 | - v += k + '=' + arg0[ k ] + ' '; | |
36 | - }; | |
37 | - alert( 'Callback.create() fail! ' + v ); | |
38 | - }; | |
27 | + if( !hash.k ) return hash; | |
39 | 28 | |
40 | - f = self._POOL_LIST.pop(); | |
29 | + f = X.Callback._POOL_LIST.pop(); | |
41 | 30 | if( !f ){ |
42 | - f = new Function( 'var a=arguments,f=a.callee;f.a=a;return f.c()' ); // f.t=this; | |
43 | - f.kill = self._kill; | |
44 | - f.same = self._same; | |
31 | + f = new Function( 'var a=arguments,f=a.callee;f.a=a;return f._(f)' ); // f.x=this; | |
32 | + f[ 'kill' ] = X.Callback._kill; | |
33 | + f[ 'same' ] = X.Callback._same; | |
34 | + f._ = X.Callback._proxyCallback; | |
45 | 35 | }; |
36 | + | |
46 | 37 | live[ live.length ] = f; |
47 | - if( listener ){ | |
48 | - f.c = self._contextCallback; | |
49 | - f.listener = listener; | |
50 | - f.context = listener; | |
51 | - f.callback = listener.handleEvent; | |
52 | - } else | |
53 | - if( context ){ | |
54 | - f.c = self._contextCallback; | |
55 | - f.context = context; | |
56 | - f.callback = callback; | |
57 | - } else { | |
58 | - f.c = self._generalCallback; | |
59 | - f.callback = callback; | |
38 | + | |
39 | + switch( f.k = hash.k ){ | |
40 | + case X.Callback._THIS_FUNC : | |
41 | + f.x = hash.x; | |
42 | + f.f = hash.f; | |
43 | + break; | |
44 | + case X.Callback._HANDLEEVENT : | |
45 | + f.x = hash.x; | |
46 | + f.f = hash.f; | |
47 | + break; | |
48 | + case X.Callback._FUNC_ONLY : | |
49 | + f.f = hash.f; | |
50 | + break; | |
60 | 51 | }; |
61 | 52 | |
62 | - if( X.Type.isArray( arg2 ) ){ | |
63 | - f.add = arg2; | |
64 | - }; | |
53 | + if( hash.s ) f.s = hash.s; | |
65 | 54 | return f; |
66 | 55 | }, |
67 | 56 | |
68 | - _contextCallback : function(){ | |
69 | - var f = this, | |
70 | - a = f.a, | |
71 | - s = f.add, | |
72 | - c = f.callback, | |
73 | - x = f.context, | |
74 | - i = 0, | |
75 | - ary, r; | |
76 | - //s && s.push.apply( a, s ); | |
77 | - if( s && s.length ){ | |
78 | - ary = []; | |
79 | - a.length && | |
80 | - ( | |
81 | - a.length === 1 ? | |
82 | - ( ary[ 0 ] = a[ 0 ] ) : | |
83 | - ary.push.apply( ary, a ) | |
84 | - ); | |
85 | - s.length === 1 ? | |
86 | - ( ary[ ary.length ] = s[ 0 ] ) : | |
87 | - ary.push.apply( ary, s ); | |
88 | - a = ary; | |
57 | + _createClosure : function( obj ){ | |
58 | + return function(){ | |
59 | + obj.a = arguments; | |
60 | + return obj._( obj ); | |
61 | + }; | |
62 | + }, | |
63 | + | |
64 | + _checkCallbackArgs : function( arg1, arg2, arg3, alt_context ){ | |
65 | + var obj; | |
66 | + | |
67 | + if( arg1 && X.Type.isFunction( arg2 ) ){ | |
68 | + obj = { x : arg1, f : arg2, k : X.Callback._THIS_FUNC }; | |
69 | + } else | |
70 | + if( arg1 && X.Type.isFunction( arg1[ 'handleEvent' ] ) ){ | |
71 | + obj = { x : arg1, f : arg1[ 'handleEvent' ], k : X.Callback._HANDLEEVENT }; | |
72 | + arg3 = arg2; | |
73 | + } else | |
74 | + if( X.Type.isFunction( arg1 ) ){ | |
75 | + arg3 = arg2; | |
76 | + if( alt_context ){ | |
77 | + obj = { x : alt_context, f : arg1, k : X.Callback._THIS_FUNC }; | |
78 | + } else { | |
79 | + obj = { f : arg1, k : X.Callback._FUNC_ONLY }; | |
80 | + }; | |
81 | + } else | |
82 | + if( X.Type.isFunction( arg2 ) ){ | |
83 | + console.log( 'X.Callback._checkCallbackArgs : arg1 が ' + arg1 + 'です' ); | |
84 | + if( alt_context ){ | |
85 | + obj = { x : alt_context, f : arg2, k : X.Callback._THIS_FUNC }; | |
86 | + } else { | |
87 | + obj = { f : arg2, k : X.Callback._FUNC_ONLY }; | |
88 | + }; | |
89 | + } else | |
90 | + if( alt_context && X.Type.isFunction( alt_context[ 'handleEvent' ] ) ){ | |
91 | + obj = { x : alt_context, f : alt_context[ 'handleEvent' ], k : X.Callback._HANDLEEVENT }; | |
92 | + arg3 = arg1; | |
93 | + } else { | |
94 | + console.log( '不正 ' + arg1 ); | |
95 | + console.dir( arg1 ); | |
96 | + return; | |
97 | + }; | |
98 | + | |
99 | + if( X.Type.isArray( arg3 )){ | |
100 | + obj.s = arg3; | |
89 | 101 | }; |
90 | - r = a.length === 0 ? c.call( x ) : c.apply( x, a ); | |
91 | - delete f.a; | |
92 | - //delete f.t; | |
93 | - return r; | |
102 | + return ( obj.x || obj.s ) ? obj : arg1; | |
94 | 103 | }, |
95 | - _generalCallback : function(){ | |
96 | - var f = this, | |
97 | - a = f.a, | |
98 | - s = f.add, | |
99 | - c = f.callback, | |
100 | - i = 0, | |
101 | - ary, r; | |
102 | - //s && s.push.apply( a, s ); | |
103 | - if( s && s.length ){ | |
104 | - ary = []; | |
105 | - a.length && | |
104 | + | |
105 | + _proxyCallback : function( xfunc ){ | |
106 | + var args = xfunc.a || [], | |
107 | + thisObj = xfunc.x, | |
108 | + func = xfunc.f, | |
109 | + supp = xfunc.s, | |
110 | + temp, ret; | |
111 | + | |
112 | + delete xfunc.a; | |
113 | + | |
114 | + if( supp && supp.length ){ | |
115 | + temp = []; | |
116 | + args.length && | |
106 | 117 | ( |
107 | - a.length === 1 ? | |
108 | - ( ary[ 0 ] = a[ 0 ] ) : | |
109 | - ary.push.apply( ary, a ) | |
118 | + args.length === 1 ? | |
119 | + ( temp[ 0 ] = args[ 0 ] ) : | |
120 | + temp.push.apply( temp, args ) | |
110 | 121 | ); |
111 | - s.length === 1 ? | |
112 | - ( ary[ ary.length ] = s[ 0 ] ) : | |
113 | - ary.push.apply( ary, s ); | |
114 | - a = ary; | |
122 | + supp.length === 1 ? | |
123 | + ( temp[ temp.length ] = supp[ 0 ] ) : | |
124 | + temp.push.apply( temp, supp ); | |
125 | + args = temp; | |
126 | + }; | |
127 | + | |
128 | + switch( xfunc.k ){ | |
129 | + | |
130 | + case X.Callback._THIS_FUNC : | |
131 | + return args.length === 0 ? func.call( thisObj ) : func.apply( thisObj, args ); | |
132 | + | |
133 | + case X.Callback._HANDLEEVENT : | |
134 | + temp = thisObj[ 'handleEvent' ]; | |
135 | + if( temp !== func && X.Type.isFunction( temp ) ){ | |
136 | + return args.length === 0 ? thisObj[ 'handleEvent' ]() : temp.apply( thisObj, args ); | |
137 | + } else | |
138 | + if( X.Type.isFunction( thisObj ) ){ | |
139 | + return args.length === 0 ? thisObj.call( thisObj ) : thisObj.apply( thisObj, args ); | |
140 | + }; | |
141 | + return args.length === 0 ? func.call( thisObj ) : func.apply( thisObj, args ); | |
142 | + | |
143 | + case X.Callback._FUNC_ONLY : | |
144 | + return args.length === 0 ? | |
145 | + func() : | |
146 | + args.length === 1 ? | |
147 | + func( args[ 0 ] ) : | |
148 | + func.apply( null, args ); | |
115 | 149 | }; |
116 | - r = a.length === 0 ? | |
117 | - c() : | |
118 | - a.length === 1 ? | |
119 | - c( a[ 0 ] ) : | |
120 | - c.apply( null, a ); | |
121 | - delete f.a; | |
122 | - //delete f.t; | |
123 | - return r; | |
124 | 150 | }, |
151 | + | |
125 | 152 | _kill : function(){ |
126 | 153 | X.Callback._correct( this ); |
127 | 154 | }, |
128 | 155 | _same : function( arg0, arg1, arg2 ){ |
129 | - var listener, context, callback, | |
130 | - f = this; | |
131 | - | |
132 | - if( arg0.kill === X.Callback._kill ){ // arg0 === X.Callback toString() で判定は? | |
133 | - return this === arg0; | |
134 | - } else | |
135 | - if( typeof arg1 === 'function' ){ | |
136 | - context = arg0; | |
137 | - callback = arg1; | |
138 | - } else | |
139 | - if( typeof arg0 === 'function' ){ | |
140 | - callback = arg0; | |
141 | - arg2 = arg1; | |
142 | - } else | |
143 | - if( arg0 && typeof arg0.handleEvent === 'function' ){ | |
144 | - listener = arg0; | |
145 | - arg2 = arg1; | |
146 | - }; | |
156 | + var hash, kind; | |
147 | 157 | |
148 | - if( arg2 && f.add !== arg2 ){ | |
149 | - return false; | |
150 | - }; | |
158 | + if( arg0 && arg0[ 'kill' ] === X.Callback._kill ) return this === arg0; | |
151 | 159 | |
152 | - if( listener && f.listener === listener ){ | |
153 | - return true; | |
154 | - } else | |
155 | - if( context && f.context === context && f.callback === callback ){ | |
156 | - return true; | |
157 | - } else | |
158 | - if( f.callback === callback ){ | |
159 | - return true; | |
160 | + hash = X.Callback._checkCallbackArgs( arg0, arg1, arg2 ), | |
161 | + kind = hash.k; | |
162 | + | |
163 | + if( this.k !== kind ) return false; | |
164 | + | |
165 | + switch( kind ){ | |
166 | + case X.Callback._THIS_FUNC : | |
167 | + return this.x === hash.x && this.f === hash.f && this.s === hash.s; | |
168 | + | |
169 | + case X.Callback._HANDLEEVENT : | |
170 | + return this.x === hash.x && this.f === hash.f && this.s === hash.s; | |
171 | + | |
172 | + case X.Callback._FUNC_ONLY : | |
173 | + return this.f === hash.f && this.s === hash.s; | |
160 | 174 | }; |
161 | 175 | return false; |
162 | 176 | }, |
163 | 177 | _correct : function( f ){ |
164 | - var self = X.Callback, | |
165 | - i = self._LIVE_LIST.indexOf( f ); | |
166 | - if( f.c ) delete f.c; | |
167 | - if( f.listener ) delete f.listener; | |
168 | - if( f.context ) delete f.context; | |
169 | - if( f.callback ) delete f.callback; | |
170 | - if( f.add ) delete f.add; | |
178 | + var i = X.Callback._LIVE_LIST.indexOf( f ); | |
179 | + //delete f._; | |
180 | + delete f.k; | |
181 | + if( f.x ) delete f.x; | |
182 | + if( f.f ) delete f.f; | |
183 | + if( f.s ) delete f.s; | |
171 | 184 | if( i === -1 ) return; |
172 | - self._LIVE_LIST.splice( i, 1 ); | |
173 | - self._POOL_LIST.push( f ); | |
185 | + X.Callback._LIVE_LIST.splice( i, 1 ); | |
186 | + X.Callback._POOL_LIST.push( f ); | |
174 | 187 | }, |
188 | + | |
175 | 189 | sys_monitor : function(){ |
176 | 190 | return { |
177 | 191 | 'Live callback' : X.Callback._LIVE_LIST.length, |
@@ -179,13 +193,14 @@ X.Callback = { | ||
179 | 193 | }; |
180 | 194 | }, |
181 | 195 | sys_gc : function(){ |
182 | - var self = X.Callback, | |
183 | - list = self._POOL_LIST, f; | |
196 | + var list = X.Callback._POOL_LIST, | |
197 | + f; | |
184 | 198 | while( 0 < list.length ){ |
185 | 199 | f = list.shift(); |
186 | - self._correct( f ); | |
187 | - delete f.kill; | |
188 | - delete f.same; | |
200 | + X.Callback._correct( f ); | |
201 | + delete f[ '_' ]; | |
202 | + delete f[ 'kill' ]; | |
203 | + delete f[ 'same' ]; | |
189 | 204 | }; |
190 | 205 | } |
191 | 206 | }; |
@@ -27,8 +27,8 @@ X.Timer = { | ||
27 | 27 | next : 0, |
28 | 28 | busy : false, // for Opera7 |
29 | 29 | |
30 | - REQUEST_FRAME_LIST : [], | |
31 | - requestID : 0, | |
30 | + REQ_FRAME_LIST : [], | |
31 | + requestID : 0, | |
32 | 32 | |
33 | 33 | _loop : function(){ |
34 | 34 | var next = X.Timer.next, |
@@ -44,17 +44,23 @@ X.Timer = { | ||
44 | 44 | |
45 | 45 | for( ; i; ){ |
46 | 46 | q = list[ --i ]; |
47 | - if( 0 < ( q.l -= next ) ) continue; | |
48 | - f = q.f; | |
49 | - c = q.c; | |
50 | - if( f() & X.Callback.UN_LISTEN || c === 1 ){ | |
47 | + if( 0 < ( q.last -= next ) ) continue; | |
48 | + c = q.count; | |
49 | + | |
50 | + if( q.k ){ | |
51 | + q.a = []; | |
52 | + r = X.Callback._proxyCallback( q ); | |
53 | + } else { | |
54 | + r = q.f(); | |
55 | + }; | |
56 | + | |
57 | + if( r & X.Callback.UN_LISTEN || c === 1 ){ | |
51 | 58 | list.splice( i, 1 ); |
52 | - f.kill && f.kill(); | |
53 | - //queue.length = 0; | |
59 | + //f.kill && f.kill(); | |
54 | 60 | continue; |
55 | 61 | } else |
56 | - if( 1 < c ) --q.c; | |
57 | - q.l = q.t; | |
62 | + if( 1 < c ) --q.count; | |
63 | + q.last = q.time; | |
58 | 64 | }; |
59 | 65 | X.Timer.timerId = 0; |
60 | 66 | X.Timer.busy = false; |
@@ -71,7 +77,7 @@ X.Timer = { | ||
71 | 77 | return; |
72 | 78 | }; |
73 | 79 | for( ; i; ){ |
74 | - ( l = list[ --i ].l ) < n && ( n = l ); | |
80 | + ( l = list[ --i ].last ) < n && ( n = l ); | |
75 | 81 | }; |
76 | 82 | if( n < X.Timer.next || X.Timer.timerId === 0 ){ |
77 | 83 | X.Timer.timerId && window.clearTimeout( X.Timer.timerId ); |
@@ -82,36 +88,45 @@ X.Timer = { | ||
82 | 88 | }, |
83 | 89 | |
84 | 90 | _onEnterFrame : function ( time ){ |
85 | - var list = X.Timer.REQUEST_FRAME_LIST, | |
91 | + var list = X.Timer.REQ_FRAME_LIST, | |
86 | 92 | i = list.length, |
87 | - f; | |
93 | + q; | |
88 | 94 | time = time || ( Date.now ? Date.now() : +new Date ); |
89 | 95 | for( ; i; ){ |
90 | - ( f = list[ --i ] )( time ); | |
91 | - delete f.uid; | |
92 | - f.kill && f.kill(); | |
96 | + q = list[ --i ]; | |
97 | + | |
98 | + if( q.k ){ | |
99 | + q.a = [ time ]; | |
100 | + X.Callback._proxyCallback( q ); | |
101 | + } else { | |
102 | + q.f( time ); | |
103 | + }; | |
104 | + //delete f.uid; | |
105 | + //f.kill && f.kill(); | |
93 | 106 | }; |
94 | 107 | list.length = 0; |
95 | 108 | }, |
96 | 109 | |
97 | 110 | add : function( time, opt_count, args1, args2, args3 ){ |
98 | - var list = X.Timer.TICKET_LIST; | |
99 | - time = time < X.Timer.INTERVAL_TIME ? 1 : ( time / X.Timer.INTERVAL_TIME ) | 0; // 正の数で使える「Math.floor(x)」を「(x | 0)」に; | |
111 | + var list = X.Timer.TICKET_LIST, | |
112 | + hash, obj; | |
113 | + time = time < X.Timer.INTERVAL_TIME ? 1 : time / X.Timer.INTERVAL_TIME | 0; // 正の数で使える「Math.floor(x)」を「(x | 0)」に; | |
100 | 114 | |
101 | - if( typeof opt_count !== 'number' ){ | |
115 | + if( !X.Type.isNumber( opt_count ) ){ | |
102 | 116 | args3 = args2; |
103 | 117 | args2 = args1; |
104 | 118 | args1 = opt_count; |
105 | 119 | opt_count = 0; |
106 | 120 | }; |
107 | - | |
108 | - list[ list.length ] = { | |
109 | - t : time, | |
110 | - l : time, | |
111 | - c : opt_count, | |
112 | - f : X.Callback.create( args1, args2, args3 ), | |
113 | - u : ++X.Timer.uid | |
114 | - }; | |
121 | + | |
122 | + hash = X.Callback._checkCallbackArgs( args1, args2, args3 ); | |
123 | + if( !hash.k ) hash = { f : hash }; | |
124 | + hash.time = time; | |
125 | + hash.last = time; | |
126 | + hash.count = opt_count; | |
127 | + hash.uid = ++X.Timer.uid; | |
128 | + list[ list.length ] = hash; | |
129 | + | |
115 | 130 | !X.Timer.busy && X.Timer._update(); |
116 | 131 | return X.Timer.uid; |
117 | 132 | }, |
@@ -126,10 +141,10 @@ X.Timer = { | ||
126 | 141 | for( ; i; ){ |
127 | 142 | // TODO |
128 | 143 | // fire 中の cancel |
129 | - if( ( q = list[ --i ] ).u === uid ){ | |
144 | + if( ( q = list[ --i ] ).uid === uid ){ | |
130 | 145 | list.splice( i, 1 ); |
131 | - f = q.f; | |
132 | - f.kill && f.kill(); | |
146 | + //f = q.f; | |
147 | + //f.kill && f.kill(); | |
133 | 148 | !X.Timer.busy && ( /* q[ INDEX_COUNT ] <= next || */ l === 1 ) && X.Timer._update(); |
134 | 149 | //q.length = 0; |
135 | 150 | break; |
@@ -139,23 +154,23 @@ X.Timer = { | ||
139 | 154 | |
140 | 155 | requestFrame : _enterFrame ? |
141 | 156 | (function( args1, args2, args3 ){ |
142 | - var i = X.Timer.REQUEST_FRAME_LIST.length, | |
157 | + var i = X.Timer.REQ_FRAME_LIST.length, | |
143 | 158 | f; |
144 | 159 | i === 0 && ( X.Timer.requestID = _enterFrame( X.Timer._onEnterFrame ) ); |
145 | - f = X.Timer.REQUEST_FRAME_LIST[ i ] = X.Callback.create( args1, args2, args3 ); | |
160 | + f = X.Timer.REQ_FRAME_LIST[ i ] = X.Callback._checkCallbackArgs( args1, args2, args3 ); | |
146 | 161 | return f.uid = ++X.Timer.uid; |
147 | 162 | }) : |
148 | 163 | (function( args1, args2, args3 ){ |
149 | - var i = X.Timer.REQUEST_FRAME_LIST.length, | |
164 | + var i = X.Timer.REQ_FRAME_LIST.length, | |
150 | 165 | f; |
151 | 166 | i === 0 && ( X.Timer.requestID = X.Timer.add( 0, 1, X.Timer._onEnterFrame ) ); |
152 | - f = X.Timer.REQUEST_FRAME_LIST[ i ] = X.Callback.create( args1, args2, args3 ); | |
167 | + f = X.Timer.REQ_FRAME_LIST[ i ] = X.Callback._checkCallbackArgs( args1, args2, args3 ); | |
153 | 168 | return f.uid = ++X.Timer.uid; |
154 | 169 | }), |
155 | 170 | |
156 | 171 | cancelFrame : _cancelFrame ? |
157 | 172 | (function( uid ){ |
158 | - var list = X.Timer.REQUEST_FRAME_LIST, | |
173 | + var list = X.Timer.REQ_FRAME_LIST, | |
159 | 174 | l = list.length, |
160 | 175 | i = l, |
161 | 176 | f; |
@@ -165,15 +180,15 @@ X.Timer = { | ||
165 | 180 | // TODO |
166 | 181 | // fire 中の cancel |
167 | 182 | list.splice( i, 1 ); |
168 | - delete f.uid; | |
169 | - f.kill && f.kill(); | |
183 | + //delete f.uid; | |
184 | + //f.kill && f.kill(); | |
170 | 185 | l === 1 && _cancelFrame( X.Timer.requestID ); |
171 | 186 | break; |
172 | 187 | }; |
173 | 188 | }; |
174 | 189 | }) : |
175 | 190 | (function( uid ){ |
176 | - var list = X.Timer.REQUEST_FRAME_LIST, | |
191 | + var list = X.Timer.REQ_FRAME_LIST, | |
177 | 192 | l = list.length, |
178 | 193 | i = l, |
179 | 194 | f; |
@@ -181,8 +196,8 @@ X.Timer = { | ||
181 | 196 | if( ( f = list[ --i ] ).uid < uid ) break; |
182 | 197 | if( f.uid === uid ){ |
183 | 198 | list.splice( i, 1 ); |
184 | - delete f.uid; | |
185 | - f.kill && f.kill(); | |
199 | + //delete f.uid; | |
200 | + //f.kill && f.kill(); | |
186 | 201 | l === 1 && X.Timer.remove( X.Timer.requestID ); |
187 | 202 | break; |
188 | 203 | }; |
@@ -194,15 +209,15 @@ X.Timer = { | ||
194 | 209 | // http://havelog.ayumusato.com/develop/javascript/e528-ios6_scrolling_timer_notcall.html |
195 | 210 | // iOS6 スクロール中のタイマー発火絡みのバグ備忘 |
196 | 211 | if( X.UA.iOS ){ |
197 | - window.addEventListener( 'scroll', function(){ | |
198 | - if( X.Timer.timerId ){ | |
199 | - window.clearTimeout( X.Timer.timerId ); | |
200 | - X.Timer.timerId = window.setTimeout( X.Timer._loop, Math.max( 0, X.Timer.endTime - X.getTime() ) ); | |
201 | - }; | |
202 | - } ); | |
212 | + window.addEventListener( 'scroll', function(){ | |
213 | + if( X.Timer.timerId ){ | |
214 | + window.clearTimeout( X.Timer.timerId ); | |
215 | + X.Timer.timerId = window.setTimeout( X.Timer._loop, Math.max( 0, X.Timer.endTime - X.getTime() ) ); | |
216 | + }; | |
217 | + }); | |
203 | 218 | }; |
204 | 219 | |
205 | -if( X.UA.IE && ( X.UA.IE < 5 || X.UA.MacIE ) ){ | |
220 | +if( X.UA.IE < 5 || X.UA.MacIE ){ | |
206 | 221 | X.Timer[ '_ie_loop' ] = X.Timer._loop; |
207 | 222 | X.Timer._loop = 'X.Timer._ie_loop()'; |
208 | 223 | }; |
@@ -35,8 +35,6 @@ X.EventDispatcher = | ||
35 | 35 | var list = this._listeners, |
36 | 36 | r, f; |
37 | 37 | if( this._dispatching ){ |
38 | - // todo | |
39 | - // reserve | |
40 | 38 | if( !this._reserves ) this._reserves = []; |
41 | 39 | this._reserves[ this._reserves.length ] = [ type, arg1, arg2, arg3, X.EventDispatcher._once ]; |
42 | 40 | return this; |
@@ -45,11 +43,17 @@ X.EventDispatcher = | ||
45 | 43 | |
46 | 44 | if( !list ) list = this._listeners = {}; |
47 | 45 | if( !( list = list[ type ] ) ) list = this._listeners[ type ] = []; |
48 | - list[ list.length ] = f = | |
49 | - ( arg1 && !arg2 ) ? | |
50 | - arg1 : | |
51 | - X.Callback.create( arg1, arg2, arg3 ); // TODO create しないで、arg1~arg3 を保持 | |
46 | + | |
47 | + f = X.Callback._checkCallbackArgs( arg1, arg2, arg3 ); | |
48 | + if( !f.k ){ | |
49 | + f = X.Callback._checkCallbackArgs( this, arg1 ); | |
50 | + } else | |
51 | + if( f.k === X.Callback._FUNC_ONLY ){ | |
52 | + f = X.Callback._checkCallbackArgs( this, f.f, f.s ); | |
53 | + }; | |
54 | + list[ list.length ] = f; | |
52 | 55 | f.once = X.EventDispatcher._once; |
56 | + | |
53 | 57 | return this; |
54 | 58 | }, |
55 | 59 | listenOnce : function( type, arg1, arg2, arg3 ){ |
@@ -116,19 +120,32 @@ X.EventDispatcher = | ||
116 | 120 | return this; |
117 | 121 | }, |
118 | 122 | listening : function( type, arg1, arg2, arg3 ){ |
119 | - var list = this._listeners, unlistens, i, f; | |
123 | + var list = this._listeners, unlistens, i, f, hash; | |
120 | 124 | if( type === undefined ) return !!list; |
121 | 125 | if( !list || !( list = list[ type ] ) ) return false; |
122 | 126 | if( arg1 === undefined ) return true; |
127 | + | |
128 | + if( arg1.k ){ | |
129 | + hash = arg1; | |
130 | + } else { | |
131 | + hash = X.Callback._checkCallbackArgs( arg1, arg2, arg3 ); | |
132 | + if( !hash.k ){ | |
133 | + hash = X.Callback._checkCallbackArgs( this, arg1 ); | |
134 | + } else | |
135 | + if( hash.k === X.Callback._FUNC_ONLY ){ | |
136 | + hash = X.Callback._checkCallbackArgs( this, hash.f, hash.s ); | |
137 | + }; | |
138 | + }; | |
139 | + | |
123 | 140 | if( ( unlistens = this._unlistens ) && ( unlistens = unlistens[ type ] ) ){ |
124 | 141 | for( i = unlistens.length; i; ){ |
125 | 142 | f = unlistens[ --i ]; |
126 | - if( f === arg1 || ( f.same && f.same( arg1, arg2, arg3 ) ) ) return false; | |
143 | + if( f === hash || ( f.x === hash.x && f.f === hash.f && f.s === hash.s ) ) return false; | |
127 | 144 | }; |
128 | 145 | }; |
129 | 146 | for( i = list.length; i; ){ |
130 | 147 | f = list[ --i ]; |
131 | - if( f === arg1 || ( f.same && f.same( arg1, arg2, arg3 ) ) ) return this._needsIndex ? i : true; | |
148 | + if( f === hash || ( f.x === hash.x && f.f === hash.f && f.s === hash.s ) ) return this._needsIndex ? i : true; | |
132 | 149 | }; |
133 | 150 | return false; |
134 | 151 | }, |
@@ -166,10 +183,16 @@ X.EventDispatcher = | ||
166 | 183 | unlistens = this._unlistens[ type ]; |
167 | 184 | }; |
168 | 185 | if( unlistens && unlistens.indexOf( f ) !== -1 ) continue; |
169 | - | |
170 | - r = typeof f === 'function' ? f( e ) : f.handleEvent( e ); // dispatch 中に unlisten が作られることがある | |
186 | + | |
187 | + if( f.k ){ | |
188 | + f.a = [ e ]; | |
189 | + r = X.Callback._proxyCallback( f ); | |
190 | + } else { | |
191 | + r = f.call( this, e ); | |
192 | + }; | |
171 | 193 | |
172 | 194 | if( f.once || r & X.Callback.UN_LISTEN ){ |
195 | + // dispatch 中に unlisten が作られることがある | |
173 | 196 | if( !unlistens ){ |
174 | 197 | unlistens = this._unlistens || ( this._unlistens = {} ); |
175 | 198 | unlistens = unlistens[ type ] || ( unlistens[ type ] = [] ); |
@@ -226,7 +249,7 @@ X.EventDispatcher = | ||
226 | 249 | }, |
227 | 250 | |
228 | 251 | asyncDispatch : function( delay, e ){ |
229 | - return X.Timer.once( delay, this, this.dispatch, [ e ] ); | |
252 | + return X.Timer.add( delay, 1, this, this.dispatch, [ e ] ); | |
230 | 253 | } |
231 | 254 | } |
232 | 255 | ); |
@@ -43,6 +43,8 @@ X.Dom = X.Class._override( | ||
43 | 43 | |
44 | 44 | }) : |
45 | 45 | (function( e ){ |
46 | + console.log( '-- resize : ' + X.getTime() ); | |
47 | + | |
46 | 48 | !X.Dom._lock && ( X.Dom._lock = true ) && X.Timer.once( 100, X.Dom._detectFinishResizing ); |
47 | 49 | return X.Callback.PREVENT_DEFAULT | X.Callback.STOP_PROPAGATION; |
48 | 50 | }), |
@@ -54,8 +56,14 @@ X.Dom = X.Class._override( | ||
54 | 56 | X.Dom.h = size[ 1 ]; |
55 | 57 | X.Timer.once( 100, X.Dom._detectFinishResizing ); |
56 | 58 | } else { |
59 | + console.log( '-- detectFinishResizing : ' + X.getTime() ); | |
60 | + | |
57 | 61 | X.Dom.asyncDispatch( 0, { type : X.Dom.Event.VIEW_RESIZED, w : X.Dom.w, h : X.Dom.h } ); |
58 | 62 | X.Dom._lock = false; |
63 | + if( X.Dom._orientationFlag ){ | |
64 | + X.Dom._orientationFlag = false; | |
65 | + X.Dom.asyncDispatch( 100, { type : X.Dom.Event.VIEW_TURNED, orientation : window.orientation } ); | |
66 | + }; | |
59 | 67 | }; |
60 | 68 | }, |
61 | 69 |
@@ -79,6 +87,9 @@ X.Dom = X.Class._override( | ||
79 | 87 | null; |
80 | 88 | |
81 | 89 | r = Node._body = new Node( document.body ); |
90 | + | |
91 | + Node.root = r; // 後方互換 | |
92 | + | |
82 | 93 | h.appendTo = h.appendToRoot = h.before = h.after = h.clone = h.remove = h.destroy = h.prevNode = h.nextNode = h.createText = h.append = h.appendAt = h.empty = h.html = h.text = |
83 | 94 | r.appendTo = r.appendToRoot = r.before = r.after = r.clone = r.remove = r.destroy = r.prevNode = r.nextNode = new Function( 'return this' ); |
84 | 95 |
@@ -104,7 +115,11 @@ X.Dom = X.Class._override( | ||
104 | 115 | |
105 | 116 | X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){ |
106 | 117 | var size = X.Dom._getSize(); |
107 | - | |
118 | + | |
119 | + if( X.Dom._orientationchange ){ | |
120 | + X.Dom.Node._window.listen( 'orientationchange', X.Dom._orientationchange ); | |
121 | + }; | |
122 | + | |
108 | 123 | if( X.Dom._detectFontSize ){ |
109 | 124 | X.Dom.Node._window.listen( 'resize', X.Dom._resize ); |
110 | 125 | X.Timer.add( 333, X.Dom._detectFontSize ); |
@@ -409,4 +424,12 @@ X.Dom.getAbsolutePath = function( path ){ | ||
409 | 424 | return [ _ary[ 0 ], ss, ary.join( s ), s, path ].join( '' ); |
410 | 425 | }; |
411 | 426 | |
427 | +if( window[ 'orientation' ] !== undefined ){ | |
428 | + X.Dom._orientationchange = function( e ){ | |
429 | + X.Dom._orientationFlag = true; | |
430 | + console.log( '-- orientationchange : ' + X.getTime() ); | |
431 | + }; | |
432 | +}; | |
433 | + | |
434 | + | |
412 | 435 | console.log( 'X.Dom dom:w3c=' + X.Dom.DOM_W3C + ' ev:w3c=' + X.Dom.EVENT_W3C ); |
@@ -783,6 +783,10 @@ Node.prototype.text = function( text ){ | ||
783 | 783 | return this; |
784 | 784 | }; |
785 | 785 | if( !text ) return this.empty(); |
786 | + if( ( xnodes = this._xnodes ) && xnodes.length === 1 && xnodes[ 0 ]._xnodeType === 3 ){ | |
787 | + xnodes[ 0 ].text( text ); | |
788 | + return this; | |
789 | + }; | |
786 | 790 | this.empty().createText( text ); |
787 | 791 | return this; |
788 | 792 | }; |
@@ -855,7 +859,7 @@ Node.prototype._startUpdate = function(){ | ||
855 | 859 | removal.length = 0; |
856 | 860 | }; |
857 | 861 | |
858 | - console.log( 'start _startUpdate().' ); | |
862 | + //console.log( 'start _startUpdate().' ); | |
859 | 863 | |
860 | 864 | Node._html._dirty ? Node._html._commitUpdate() : this._commitUpdate(); |
861 | 865 |
@@ -7,6 +7,7 @@ | ||
7 | 7 | |
8 | 8 | if( X.Dom.EVENT_W3C ){ |
9 | 9 | X.Dom.Event = function( e, xnode ){ |
10 | + var touch0; | |
10 | 11 | //this._event = e; |
11 | 12 | this.type = X.Dom.Event.RenameTo[ e.type ] || e.type; |
12 | 13 |
@@ -63,6 +64,16 @@ if( X.Dom.EVENT_W3C ){ | ||
63 | 64 | this.targetTouches = e.targetTouches; |
64 | 65 | this.metaKey = e.metaKey; |
65 | 66 | this.force = e.force || e.webkitForce || 0; |
67 | + // | |
68 | + if( this.touches.length ){ | |
69 | + touch0 = this.touches[ 0 ]; | |
70 | + this.clientX = touch0.clientX; | |
71 | + this.clientY = touch0.clientY; | |
72 | + this.pageX = touch0.pageX; | |
73 | + this.pageY = touch0.pageY; | |
74 | + this.offsetX = touch0.offsetX || touch0.layerX; | |
75 | + this.offsetY = touch0.offsetY || touch0.layerY; | |
76 | + }; | |
66 | 77 | } else |
67 | 78 | if( e.constructor === window.PointerEvent ){ |
68 | 79 | // PointerEvent; |
@@ -80,6 +91,9 @@ if( X.Dom.EVENT_W3C ){ | ||
80 | 91 | this.tiltY = e.tiltY; |
81 | 92 | }; |
82 | 93 | }; |
94 | + if( !window.PointerEvent && window.MSPointerEvent ){ | |
95 | + window.PointerEvent = window.MSPointerEvent; | |
96 | + }; | |
83 | 97 | } else { |
84 | 98 | X.Dom.Event = function( e, xnode, element ){ |
85 | 99 | var btn; |
@@ -150,6 +164,7 @@ X.Dom.Event.XDOM_READY = ++X.Event._LAST_EVENT; | ||
150 | 164 | X.Dom.Event.VIEW_ACTIVATE = ++X.Event._LAST_EVENT; |
151 | 165 | X.Dom.Event.VIEW_DEACTIVATE = ++X.Event._LAST_EVENT; |
152 | 166 | X.Dom.Event.VIEW_RESIZED = ++X.Event._LAST_EVENT; |
167 | +X.Dom.Event.VIEW_TURNED = ++X.Event._LAST_EVENT; | |
153 | 168 | X.Dom.Event.BASE_FONT_RESIZED = ++X.Event._LAST_EVENT; |
154 | 169 | // same_page_jump |
155 | 170 | // on_screen_keyboard_show |
@@ -177,6 +192,7 @@ X.Dom.Event.RenameTo = {}; | ||
177 | 192 | // https://github.com/georgeadamson/jQuery.prefixfree-events/blob/master/jQuery.prefixfree-events.js |
178 | 193 | |
179 | 194 | if( window.onwebkitanimationend !== undefined && window.onanimationend === undefined ){ |
195 | + console.log( 'animationend <= webkitAnimationEnd' ); | |
180 | 196 | X.Dom.Event.Rename[ 'animationend' ] = 'webkitAnimationEnd'; |
181 | 197 | X.Dom.Event.RenameTo[ 'webkitAnimationEnd' ] = 'animationend'; |
182 | 198 | X.Dom.Event.Rename[ 'animationstart' ] = 'webkitAnimationStart'; |
@@ -185,6 +201,7 @@ if( window.onwebkitanimationend !== undefined && window.onanimationend === undef | ||
185 | 201 | X.Dom.Event.RenameTo[ 'webkitAnimationIteration' ] = 'animationiteration'; |
186 | 202 | } else |
187 | 203 | if( window.onoanimationend !== undefined && window.onanimationend === undefined ){ |
204 | + console.log( 'animationend <= oAnimationEnd' ); | |
188 | 205 | X.Dom.Event.Rename[ 'animationend' ] = 'oAnimationEnd'; |
189 | 206 | X.Dom.Event.RenameTo[ 'oAnimationEnd' ] = 'animationend'; |
190 | 207 | X.Dom.Event.Rename[ 'animationstart' ] = 'oAnimationStart'; |
@@ -202,6 +219,7 @@ if( window.onmozanimationend !== undefined && window.onanimationend === undefine | ||
202 | 219 | X.Dom.Event.RenameTo[ 'mozAnimationIteration' ] = 'animationiteration'; |
203 | 220 | } else*/ |
204 | 221 | if( document.documentElement && document.documentElement.style.msAnimation !== undefined && document.documentElement.style.animation === undefined ){ //document.documentElement.style.msAnimation |
222 | + console.log( 'animationend <= MSAnimationEnd' ); | |
205 | 223 | X.Dom.Event.Rename[ 'animationend' ] = 'MSAnimationEnd'; |
206 | 224 | X.Dom.Event.RenameTo[ 'MSAnimationEnd' ] = 'animationend'; |
207 | 225 | X.Dom.Event.Rename[ 'animationstart' ] = 'MSAnimationStart'; |
@@ -212,25 +230,30 @@ if( document.documentElement && document.documentElement.style.msAnimation !== u | ||
212 | 230 | // https://developer.mozilla.org/en-US/docs/Web/Events/transitionend |
213 | 231 | // chrome1+, firefox4+, IE10+, Opera10.5+, Safari3.2+, Android2.1+ |
214 | 232 | if( window.onwebkittransitionend !== undefined && window.ontransitionend === undefined ){ |
233 | + console.log( 'transitionend <= webkitTransitionEnd' ); | |
215 | 234 | X.Dom.Event.Rename[ 'transitionend' ] = 'webkitTransitionEnd'; |
216 | 235 | X.Dom.Event.RenameTo[ 'webkitTransitionEnd' ] = 'transitionend'; |
217 | 236 | } else |
218 | 237 | if( window.onotransitionend !== undefined && window.ontransitionend === undefined ){ |
219 | 238 | if( X.UA.Opera < 12 ){ |
239 | + console.log( 'transitionend <= oTransitionEnd|ver.' + X.UA.Opera ); | |
220 | 240 | X.Dom.Event.Rename[ 'transitionend' ] = 'oTransitionEnd'; |
221 | 241 | X.Dom.Event.RenameTo[ 'oTransitionEnd' ] = 'transitionend'; |
222 | 242 | } else { |
243 | + console.log( 'transitionend <= otransitionEnd|ver.' + X.UA.Opera ); | |
223 | 244 | X.Dom.Event.Rename[ 'transitionend' ] = 'otransitionEnd'; |
224 | 245 | X.Dom.Event.RenameTo[ 'otransitionEnd' ] = 'transitionend'; |
225 | 246 | }; |
226 | 247 | } else |
227 | 248 | if( window.onmoztransitionend !== undefined && window.ontransitionend === undefined ){ |
249 | + console.log( 'transitionend <= mozTransitionEnd' ); | |
228 | 250 | X.Dom.Event.Rename[ 'transitionend' ] = 'mozTransitionEnd'; |
229 | 251 | X.Dom.Event.RenameTo[ 'mozTransitionEnd' ] = 'transitionend'; |
230 | 252 | }; |
231 | 253 | |
232 | 254 | |
233 | 255 | if( navigator.msPointerEnabled && !navigator.pointerEnabled ){ |
256 | + console.log( 'pointerdown <= MSPointerDown' ); | |
234 | 257 | X.Dom.Event.Rename[ 'pointerdown' ] = 'MSPointerDown'; |
235 | 258 | X.Dom.Event.RenameTo[ 'MSPointerDown' ] = 'pointerdown'; |
236 | 259 | X.Dom.Event.Rename[ 'pointerup' ] = 'MSPointerUp'; |
@@ -243,16 +266,12 @@ if( navigator.msPointerEnabled && !navigator.pointerEnabled ){ | ||
243 | 266 | |
244 | 267 | |
245 | 268 | |
246 | -X.Dom.Node.prototype.listen = function( type, arg1, arg2, arg3 /* [ listener || ( context + function ) || function ][ arguments ] */ ){ | |
247 | - var elm; | |
248 | - | |
249 | - if( this._xnodeType === 0 || this._xnodeType === 3 || !arg1 ) return this; | |
269 | +X.Dom.Node.prototype.listen = function( type /* , arg1, arg2, arg3[ listener || ( context + function ) || function ][ arguments ] */ ){ | |
270 | + if( this._xnodeType === 0 || this._xnodeType === 3 ) return this; | |
250 | 271 | |
251 | 272 | ( !this._listeners || !this._listeners[ type ] ) && X.Type.isString( type ) && this._addEvent( type ); |
252 | 273 | |
253 | - return typeof arg1 === 'function' ? | |
254 | - X.EventDispatcher.prototype.listen.call( this, type, this, arg1, arg2 ) : | |
255 | - X.EventDispatcher.prototype.listen.apply( this, arguments ); | |
274 | + return X.EventDispatcher.prototype.listen.apply( this, arguments ); | |
256 | 275 | }; |
257 | 276 | |
258 | 277 | X.Dom.Node.prototype._addEvent = |
@@ -70,4 +70,5 @@ _text = X.Class._getPrivate( text ); | ||
70 | 70 | |
71 | 71 | function _onClick( e ){ |
72 | 72 | alert( e.type ); |
73 | + console.log( e.type + ' -----------' ); | |
73 | 74 | }; |
@@ -38,6 +38,7 @@ | ||
38 | 38 | pointerType, i, l, touches, ret, active, gesture, startEv, |
39 | 39 | hammer, deltaTime, deltaX, deltaY, velocity; |
40 | 40 | |
41 | + //console.log( 'Hammer@handleEvent ' + X.UI.Event.IdToName[ e.type ] + ' ' + e.pointerType ); | |
41 | 42 | if( !type ) return; |
42 | 43 | |
43 | 44 | if( e.pointerType ){ |
@@ -212,7 +213,7 @@ | ||
212 | 213 | // only when the instance options have enabled this gesture |
213 | 214 | active[ gesture.name ] && |
214 | 215 | // if a handler returns false, we stop with the detection |
215 | - ( ret |= ( gesture.handler.call( gesture, e, hammer ) || X.Callback.NONE ) ); | |
216 | + ( ret |= ( gesture.handler( e, hammer ) || X.Callback.NONE ) ); | |
216 | 217 | }; |
217 | 218 | |
218 | 219 | // endevent, but not the last touch, so dont stop |
@@ -325,6 +326,8 @@ | ||
325 | 326 | |
326 | 327 | // detect touchevents |
327 | 328 | Hammer.HAS_POINTEREVENTS = navigator.pointerEnabled || navigator.msPointerEnabled; |
329 | + Hammer.HAS_POINTEREVENTS && console.log( 'Hammer.HAS_POINTEREVENTS : true' ); | |
330 | + | |
328 | 331 | |
329 | 332 | // eventtypes per touchevent (start, move, end) |
330 | 333 | // are filled by HamEvent.determineEventTypes on setup |
@@ -72,8 +72,8 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits( | ||
72 | 72 | this.dispatch( { type : X.UI.Event.INIT } ); |
73 | 73 | }, |
74 | 74 | |
75 | - addToParent : function( parentElement ){ | |
76 | - parentElement && parentElement.append( this.xnode ); | |
75 | + addToParent : function( xnodeParent ){ | |
76 | + xnodeParent && xnodeParent.append( this.xnode ); | |
77 | 77 | |
78 | 78 | this.phase = 2; |
79 | 79 | this.dispatch( { type : X.UI.Event.ADDED } ); |
@@ -745,7 +745,6 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits( | ||
745 | 745 | y -= this.boxY; |
746 | 746 | |
747 | 747 | if( 0 <= x && x < this.boxWidth && 0 <= y && y < this.boxHeight ){ |
748 | - | |
749 | 748 | !this.hovering && ( this.rootData.hoverList[ this.rootData.hoverList.length ] = this ); |
750 | 749 | this.rootData.targetNodeData = this; |
751 | 750 | return true; |
@@ -754,7 +753,7 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits( | ||
754 | 753 | |
755 | 754 | |
756 | 755 | listen : function( type, arg1, arg2, arg3 ){ |
757 | - var root, events, counter; | |
756 | + var root, events, counter, f; | |
758 | 757 | if( X.UI.Event._START_POINTER <= type && type <= X.UI.Event._END_POINTER ){ |
759 | 758 | if( this.phase < 3 ){ |
760 | 759 | if( !( events = this.reserveEvents ) ) this.reserveEvents = events = []; |
@@ -763,12 +762,12 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits( | ||
763 | 762 | }; |
764 | 763 | if( X.UI.Event._START_XUI_EVENT < type && type < X.UI.Event._END_XUI_EVENT ){ |
765 | 764 | if( !this.gesture ){ |
766 | - this.gesture = new X.UI.Gesture( this.root, this, type ); | |
765 | + this.gesture = new X.UI.Gesture( this.rootData, this, type ); | |
767 | 766 | } else { |
768 | 767 | this.gesture.listen( type ); |
769 | 768 | }; |
770 | 769 | } else { |
771 | - console.log( type ) | |
770 | + console.log( type ); | |
772 | 771 | root = this.rootData; |
773 | 772 | counter = root.eventCounter; |
774 | 773 | if( counter[ type ] ){ |
@@ -779,10 +778,14 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits( | ||
779 | 778 | }; |
780 | 779 | }; |
781 | 780 | }; |
782 | - if( typeof arg1 === 'function' ){ | |
783 | - return X.EventDispatcher.prototype.listen.apply( this, [ type, this.User, arg1, arg2 ] ); | |
781 | + f = X.Callback._checkCallbackArgs( arg1, arg2, arg3 ); | |
782 | + if( !f.k ){ | |
783 | + return X.EventDispatcher.prototype.listen.apply( this, [ type, this.User, f ] ); | |
784 | + } else | |
785 | + if( f.k === X.Callback._FUNC_ONLY ){ | |
786 | + return X.EventDispatcher.prototype.listen.apply( this, [ type, this.User, f.f, f.s ] ); | |
784 | 787 | }; |
785 | - return X.EventDispatcher.prototype.listen.apply( this, [ type, arg1 || this.User, arg2 || arg1, arg3 || arg2 ] ); | |
788 | + return X.EventDispatcher.prototype.listen.apply( this, arguments ); | |
786 | 789 | }, |
787 | 790 | unlisten : function( type, arg1, arg2, arg3 ){ |
788 | 791 | var root, events, i, ev, counter; |
@@ -812,10 +815,14 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits( | ||
812 | 815 | }; |
813 | 816 | }; |
814 | 817 | }; |
815 | - if( typeof arg1 === 'function' ){ | |
816 | - return X.EventDispatcher.prototype.unlisten.apply( this, [ type, this.User, arg1, arg2 ] ); | |
818 | + f = X.Callback._checkCallbackArgs( arg1, arg2, arg3 ); | |
819 | + if( !f.k ){ | |
820 | + return X.EventDispatcher.prototype.unlisten.apply( this, [ type, this.User, f ] ); | |
821 | + } else | |
822 | + if( f.k === X.Callback._FUNC_ONLY ){ | |
823 | + return X.EventDispatcher.prototype.unlisten.apply( this, [ type, this.User, f.f, f.s ] ); | |
817 | 824 | }; |
818 | - return X.EventDispatcher.prototype.unlisten.apply( this, [ type, arg1 || this.User, arg2 || arg1, arg3 || arg2 ] ); | |
825 | + return X.EventDispatcher.prototype.unlisten.apply( this, arguments ); | |
819 | 826 | }, |
820 | 827 | |
821 | 828 | dispatch : function( e ){ |
@@ -918,6 +925,9 @@ X.UI.AbstractUINode = X.Class.create( | ||
918 | 925 | X.Class._getPrivate( this ).listenOnce( type, arg1, arg2, arg3 ); |
919 | 926 | return this; |
920 | 927 | }, |
928 | + listening : function( type, arg1, arg2, arg3 ){ | |
929 | + return X.Class._getPrivate( this ).listening( type, arg1, arg2, arg3 ); | |
930 | + }, | |
921 | 931 | unlisten : function( type, arg1, arg2, arg3 ){ |
922 | 932 | X.Class._getPrivate( this ).unlisten( type, arg1, arg2, arg3 ); |
923 | 933 | return this; |
@@ -14,14 +14,14 @@ X.UI._eventRellay = function( e ){ | ||
14 | 14 | data._eventBusy = true; |
15 | 15 | |
16 | 16 | if( type !== '' + X.UI.Event._POINTER_MOVE && type !== '' + X.UI.Event._TOUCH_MOVE && type !== '' + X.UI.Event._MOUSE_MOVE ){ |
17 | - // console.log( e.type + ' ' + type + ' x:' + x + ', y:' + y ); | |
17 | + //console.log( e.type + ' ' + type + ' x:' + x + ', y:' + y ); | |
18 | 18 | }; |
19 | 19 | |
20 | 20 | e.type = type; |
21 | 21 | |
22 | 22 | if( data && ( data = data.monopolyNodeData ) && ( ret = data.dispatch( e ) ) & X.Callback.MONOPOLY ){ |
23 | 23 | delete X.UI.currentRootData._eventBusy; |
24 | - return ret; | |
24 | + return ret | X.Callback.PREVENT_DEFAULT; | |
25 | 25 | }; |
26 | 26 | |
27 | 27 | list = X.UI.currentRootData.hoverList; |
@@ -56,7 +56,7 @@ X.UI._eventRellay = function( e ){ | ||
56 | 56 | }; |
57 | 57 | }; |
58 | 58 | delete X.UI.currentRootData._eventBusy; |
59 | - return ret; | |
59 | + return ret | X.Callback.PREVENT_DEFAULT; | |
60 | 60 | }; |
61 | 61 | |
62 | 62 | /* |
@@ -78,6 +78,7 @@ | ||
78 | 78 | font-weight : bold; |
79 | 79 | z-index : 999; |
80 | 80 | cursor : pointer; |
81 | + -webkit-tap-highlight-color : rgba(0,0,0,0); | |
81 | 82 | } |
82 | 83 | .toggle_close #log, |
83 | 84 | .toggle_none #toggle { |
@@ -194,7 +195,7 @@ | ||
194 | 195 | body.className = toggleOpen ? 'toggle_open' : 'toggle_close'; |
195 | 196 | }; |
196 | 197 | }; |
197 | - btn.innerHTML = toggleOpen ? '►' : '▼'; | |
198 | + btn.innerHTML = toggleOpen ? '▶' : '▼';//►▸ | |
198 | 199 | }; |
199 | 200 | function __readyTrans(){ |
200 | 201 | var body = document.body, |
@@ -238,4 +239,5 @@ | ||
238 | 239 | </noscript> |
239 | 240 | </head> |
240 | 241 | <body onload="__resize()" onresize="__resize()" scroll="no"><div id="log">-- console.log() --</div><iframe src="index.html" width="500" height="100%" scrolling="yes" frameborder="0"></iframe><div id="toggle" onclick="__ontoggle();"></div></body> |
241 | -</html> | |
\ No newline at end of file | ||
242 | +</html> | |
243 | +<xmp class="cleanup-target" style="display:none"><plaintext style="display:none"><!-- plainetext は nds 用 --> | |
\ No newline at end of file |