OSDN Git Service

Version 0.6.143, fix X.UI.ScrollBox for iOS3.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 15_ScrollBox.js
1 \r
2 \r
3 function X_UI_ScrollBox_momentum( current, start, time, lowerMargin, wrapperSize, deceleration ){\r
4         var distance = current - start,\r
5                 speed    = Math.abs( distance ) / time,\r
6                 destination,\r
7                 duration;\r
8 \r
9         deceleration = deceleration === undefined ? 0.0006 : deceleration;\r
10 \r
11         destination  = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );\r
12         duration     = speed / deceleration;\r
13 \r
14         if( destination < lowerMargin ){\r
15                 destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;\r
16                 distance    = Math.abs( destination - current );\r
17                 duration    = distance / speed;\r
18         } else\r
19         if ( destination > 0 ) {\r
20                 destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;\r
21                 distance    = Math.abs( current ) + destination;\r
22                 duration    = distance / speed;\r
23         };\r
24 \r
25         return {\r
26                 destination : Math.round( destination ),\r
27                 duration    : duration\r
28         };\r
29 };\r
30 \r
31 var X_UI_ScrollBox_SUPPORT_ATTRS = {\r
32                 // スクロール開始するために必要な移動距離、縦か横、どちらか制限する場合、より重要\r
33                 directionLockThreshold : [     10, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.LENGTH ],\r
34                 scrollXEnabled         : [   true, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.BOOLEAN ],\r
35                 scrollYEnabled         : [   true, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.BOOLEAN ],\r
36                 scrollEnabled          : [   true, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.BOOLEAN ],\r
37                 bounceEnabled          : [   true, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.BOOLEAN ],\r
38                 bounceTime             : [    600, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.TIME ],\r
39                 useWheel               : [   true, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.BOOLEAN ],\r
40                 useKey                 : [   true, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.BOOLEAN ],\r
41                 hasScrollShadow        : [   true, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.BOOLEAN ],\r
42                 scrollShadowColor      : [ '#000', XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.COLOR ]\r
43         };\r
44 \r
45 var XUI_ScrollBox = XUI_ChromeBox.inherits(\r
46         '_ScrollBox',\r
47         X_Class.PRIVATE_DATA,\r
48         {\r
49                 directionLockThreshold : 10,\r
50                 scrollXEnabled         : true,\r
51                 scrollYEnabled         : true,\r
52                 scrollEnabled          : true,\r
53                 bounceEnabled          : true,\r
54                 momentumEnabled        : true,\r
55                 bounceTime             : 600,\r
56                 useWheel               : true,\r
57                 useKey                 : true,\r
58                 hasScrollShadow        : true,\r
59                 scrollShadowColor      : '#000',\r
60                 \r
61                 supportAttrs    : XUI_Attr_createAttrDef( XUI_Attr_Support, X_UI_ScrollBox_SUPPORT_ATTRS ),\r
62                 \r
63                 scrolling       : false,\r
64                 \r
65                 initiated       : '',\r
66                 moved               : false,\r
67                 directionLocked : '',\r
68                 startTime       : 0,\r
69                 endTime         : 0,\r
70                 isAnimating     : false,\r
71                 isInTransition  : false,\r
72 \r
73                 hasHScroll      : false,\r
74                 hasVScroll      : false,\r
75 \r
76                 wrapperOffset   : 0,\r
77                 wheelTimeout    : 0,\r
78                 requestFrameID  : 0,\r
79                 \r
80                 fontSize        : 0,\r
81                 \r
82                 scrollX         : 0, // px\r
83                 scrollY         : 0, // px\r
84                 scrollXMax      : 0, // px\r
85                 scrollYMax      : 0, // px\r
86                 scrollXRatio    : 0, // この値は scroll 不要になっても保持される。 scroll 必要時に参照される\r
87                 scrollYRatio    : 0,            \r
88                 startX          : 0, // px\r
89                 startY          : 0, // px\r
90                 absStartX       : 0, // px\r
91                 absStartY       : 0, // px\r
92                 pointX          : 0, // px\r
93                 pointY          : 0, // px\r
94                 distX               : 0, // px\r
95                 distY               : 0, // px\r
96                 directionX      : 0, // -1, 0, 1\r
97                 directionY      : 0, // -1, 0, 1\r
98                 \r
99                 lastScrollWidth  : 0,\r
100                 lastScrollHeight : 0,\r
101                 lastBoxWidth     : 0,\r
102                 lastBoxHeight    : 0,\r
103                 \r
104                 _containerNode   : null,\r
105                 xnodeSlider      : null,\r
106                 \r
107                 Constructor : function( layout, args ){\r
108                         this[ 'Super' ]( layout, args );\r
109                         this._containerNode = X_Class_getPrivate( this.containerNode );\r
110                         this.xnodeSlider = this._containerNode.xnode[ 'className' ]( 'ScrollSlider' ).listen( X_EVENT_ANIME_END, this, X_UI_ScrollBox_onAnimeEnd );\r
111                         this.xnode[ 'className' ]( 'ScrollBox' );\r
112                 },\r
113                 \r
114                 creationComplete : function(){\r
115                         XUI_Box.prototype.creationComplete.apply( this, arguments );\r
116                 },\r
117                 \r
118                 calculate : function(){\r
119                         this.lastScrollWidth  = this._containerNode.boxWidth;\r
120                         this.lastScrollHeight = this._containerNode.boxHeight;\r
121                         this.lastBoxWidth     = this.boxWidth;\r
122                         this.lastBoxHeight    = this.boxHeight;\r
123                         \r
124                         XUI_Box.prototype.calculate.apply( this, arguments );\r
125                         \r
126                         // TODO root の layout_complete 後に。\r
127                         // TODO calculate 前に scroll の解放。\r
128                         \r
129                         if(\r
130                                         this.lastScrollWidth  !== this._containerNode.boxWidth ||\r
131                                         this.lastScrollHeight !== this._containerNode.boxHeight ||\r
132                                         this.lastBoxWidth    !== this.boxWidth    || this.lastBoxHeight    !== this.boxHeight\r
133                                 ){\r
134                                         X_UI_rootData[ 'listenOnce' ]( XUI_Event.LAYOUT_COMPLETE, this, X_UI_ScrollBox_onLayoutComplete );\r
135                                 };\r
136                 },\r
137         \r
138                 scrollTo : function( x, y, opt_time, opt_easing, opt_release ){\r
139                         //if( this.scrollX === x && this.scrollY === y ) return;\r
140                         \r
141                         opt_time    = 0 <= opt_time ? opt_time : 0;\r
142                         opt_easing  = opt_easing || 'circular';\r
143                         opt_release = 0 <= opt_release ? opt_release : 300;\r
144         \r
145                         this.isInTransition = 0 < opt_time;\r
146         \r
147                         X_UI_ScrollBox_translate( this, x, y, opt_time, opt_easing, opt_release );\r
148                 },\r
149                 \r
150                 _remove : function(){\r
151                         XUI_AbstractUINode.prototype._remove.apply( this, arguments );\r
152                         if( this.scrolling ){\r
153                                 // remove scroll\r
154                         };\r
155                 }\r
156                 \r
157         }\r
158 );\r
159 \r
160 function X_UI_ScrollBox_onLayoutBefore( e ){\r
161         if( e[ 'cancelable' ] && this.isInTransition && X_Node_Anime_translateZ ){\r
162                 this[ 'listenOnce' ]( XUI_Event.SCROLL_END, X_UI_rootData, X_UI_rootData.calculate );\r
163                 return X_Callback_PREVENT_DEFAULT;\r
164         };\r
165         this.scrollXRatio = this.scrollX ? this.scrollXMax / this.scrollX : 0;\r
166         this.scrollYRatio = this.scrollY ? this.scrollYMax / this.scrollY : 0;\r
167         this.xnodeSlider.stop();\r
168         this.isInTransition = false;\r
169         return X_Callback_NONE;\r
170 };\r
171 \r
172 function X_UI_ScrollBox_onLayoutComplete( e ){\r
173         // scroll の停止、GPU の解除\r
174         var font = this.fontSize = this.xnodeSlider.call( 'fontSize' );\r
175         \r
176         this.scrollXMax = ( this.boxWidth  - this._containerNode.boxWidth )  * font;\r
177         this.scrollYMax = ( this.boxHeight - this._containerNode.boxHeight ) * font;\r
178 \r
179         this.hasHScroll = this.scrollXEnabled && this.scrollXMax < 0;\r
180         this.hasVScroll = this.scrollYEnabled && this.scrollYMax < 0;\r
181 \r
182         if( !this.hasHScroll ){\r
183                 this.scrollXMax  = 0;\r
184         };\r
185 \r
186         if( !this.hasVScroll ){\r
187                 this.scrollYMax   = 0;\r
188         };\r
189 \r
190         delete this.endTime;\r
191         delete this.directionX;\r
192         delete this.directionY;\r
193 \r
194         X_UI_ScrollBox_resetPosition( this, 0 );\r
195 \r
196         if( this.hasHScroll || this.hasVScroll ){\r
197                 // scroll が必要。\r
198                 if( this.scrolling ){\r
199                         X_UI_ScrollBox_translate( this, this.scrollXMax * this.scrollXRatio, this.scrollYMax * this.scrollYRatio, 100, '', 300 );\r
200                 } else {\r
201                         // scroller 作る\r
202                         this[ 'listen' ]( XUI_Event._POINTER_DOWN, this, X_UI_ScrollBox_onStart );\r
203                         X_UI_rootData[ 'listen' ]( XUI_Event.LAYOUT_BEFORE, this, X_UI_ScrollBox_onLayoutBefore );\r
204                         \r
205                         X_UI_ScrollBox_translate( this, this.scrollXMax * this.scrollXRatio, this.scrollYMax * this.scrollYRatio, 100, '', 300 );\r
206                         this.scrolling = true;\r
207                 };\r
208         } else\r
209         // scroll 不要\r
210         if( this.scrolling ){\r
211                 // scroller 削除\r
212                 this[ 'unlisten' ]( XUI_Event._POINTER_DOWN, this, X_UI_ScrollBox_onStart );\r
213                 X_UI_rootData[ 'unlisten' ]( XUI_Event.LAYOUT_BEFORE,   this, X_UI_ScrollBox_onLayoutBefore );\r
214                 \r
215                 ( this.scrollX !== 0 || this.scrollY !== 0 ) && X_UI_ScrollBox_translate( this, 0, 0, 100, '', 300 );\r
216                 \r
217                 delete this.scrolling;\r
218                 delete this.scrollXRatio;\r
219                 delete this.scrollYRatio;\r
220         };\r
221 };\r
222 \r
223                 // TODO use scrollLeft, scrollTop\r
224                 function X_UI_ScrollBox_translate( that, x, y, opt_time, opt_easing, opt_release ){\r
225                         \r
226                         opt_time    = 0 <= opt_time ? opt_time : 0;\r
227                         opt_easing  = opt_easing === '' ? '' : opt_easing || 'circular';\r
228                         opt_release = 0 <= opt_release ? opt_release : 300;\r
229                         \r
230                         that.xnodeSlider.animate(\r
231                                 {\r
232                                         x : that.scrollX,\r
233                                         y : that.scrollY\r
234                                 },\r
235                                 {\r
236                                         x : x,\r
237                                         y : y\r
238                                 },\r
239                                 opt_time, opt_easing, opt_release\r
240                         );\r
241                         \r
242                         that.scrollX = x;\r
243                         that.scrollY = y;\r
244                         \r
245                         if( that.indicators ){\r
246                                 for( i = that.indicators.length; i--; ){\r
247                                         that.indicators[ i ].updatePosition();\r
248                                 };\r
249                         };\r
250                 };\r
251 \r
252 function X_UI_ScrollBox_onStart( e ){\r
253         var ret = X_Callback_NONE;\r
254 \r
255         // React to left mouse button only\r
256         if( e.pointerType === 'mouse' && e.button !== 0 ){\r
257                 return ret;\r
258         };\r
259         \r
260         if( !this.scrollEnabled || ( this.initiated && e.pointerType !== this.initiated ) ){\r
261                 return ret;\r
262         };\r
263 \r
264         this.initiated       = e.pointerType;\r
265         this.moved                   = false;\r
266         this.distX                   = 0;\r
267         this.distY                   = 0;\r
268         this.directionX      = 0;\r
269         this.directionY      = 0;\r
270         this.directionLocked = '';\r
271         this.startTime       = X_Timer_now();\r
272 \r
273         // スクロール中の停止\r
274         if( this.isInTransition || this.isAnimating ){\r
275                 this.isInTransition = this.isAnimating = false;\r
276                 this[ 'dispatch' ]( XUI_Event.SCROLL_END );\r
277                 this.xnodeSlider.stop();\r
278         };                      \r
279 \r
280         this.startX    = this.scrollX;\r
281         this.startY    = this.scrollY;\r
282         this.absStartX = this.scrollX;\r
283         this.absStartY = this.scrollY;\r
284         this.pointX    = e.pageX;\r
285         this.pointY    = e.pageY;\r
286         \r
287         console.log( 'scrollstart ' + e.pageY );\r
288         \r
289         this[ 'listen' ]( XUI_Event._POINTER_MOVE, this, X_UI_ScrollBox_onMove );\r
290         this[ 'listen' ]( [ XUI_Event._POINTER_UP, XUI_Event._POINTER_CANCEL ], this, X_UI_ScrollBox_onEnd );\r
291 \r
292         return ret | X_Callback_PREVENT_DEFAULT;\r
293 };\r
294 \r
295 function X_UI_ScrollBox_onMove( e ){\r
296         var ret = X_Callback_NONE,\r
297                 deltaX, deltaY, timestamp,\r
298                 newX, newY,\r
299                 absDistX, absDistY;\r
300         // 規定以上の move でスクロール開始\r
301 \r
302 console.log( 'scrollmove ' + e.buttons + ' ' + e.button );\r
303 \r
304         if( !this.scrollEnabled || e.pointerType !== this.initiated ){\r
305                 return ret;\r
306         };\r
307         \r
308         if( e.buttons !== 1 ){\r
309                 return X_UI_ScrollBox_onEnd.call( this, e );\r
310         };\r
311 \r
312         // gpu の用意\r
313         if( !this.xnodeSlider[ '_anime' ] ){\r
314                 //console.log( 'gpuレイヤーの用意 ' + e.pageY );\r
315                 //console.log( 'mov1 x:' + this.scrollX + ' y:' + this.scrollY );\r
316                 X_UI_ScrollBox_translate( this, this.scrollX, this.scrollY, 0, '', 300 );\r
317                 return ret;\r
318         };\r
319 \r
320         deltaX          = e.pageX - this.pointX;\r
321         deltaY          = e.pageY - this.pointY;\r
322         timestamp       = X_Timer_now();\r
323 \r
324         this.pointX     = e.pageX;\r
325         this.pointY     = e.pageY;\r
326 \r
327         this.distX      += deltaX;\r
328         this.distY      += deltaY;\r
329         absDistX        = Math.abs(this.distX);\r
330         absDistY        = Math.abs(this.distY);\r
331         \r
332         // We need to move at least 10 pixels for the scrolling to initiate\r
333         if( 300 < timestamp - this.endTime && ( absDistX < 10 && absDistY < 10 ) ){\r
334                 return ret;\r
335         };\r
336 \r
337         // If you are scrolling in one direction lock the other\r
338         if( !this.directionLocked ){\r
339                 if( absDistX > absDistY + this.directionLockThreshold ){\r
340                         this.directionLocked = 'h';             // lock horizontally\r
341                 } else\r
342                 if( absDistY >= absDistX + this.directionLockThreshold ){\r
343                         this.directionLocked = 'v';             // lock vertically\r
344                 } else {\r
345                         this.directionLocked = 'n';             // no lock\r
346                 };\r
347         };\r
348 \r
349         if( this.directionLocked === 'h' ){\r
350                 deltaY = 0;\r
351         } else\r
352         if( this.directionLocked === 'v' ){\r
353                 deltaX = 0;\r
354         };\r
355 \r
356         deltaX = this.hasHScroll ? deltaX : 0;\r
357         deltaY = this.hasVScroll ? deltaY : 0;\r
358 \r
359         if( !this.moved ){\r
360                 this[ 'dispatch' ]( XUI_Event.SCROLL_BEFORE_MOVE );\r
361                 this.moved  = true;\r
362                 this.minusX = deltaX;\r
363                 this.minusY = deltaY;\r
364         } else {\r
365                 this[ 'dispatch' ]( XUI_Event.SCROLL_MOVE );\r
366         };\r
367 \r
368         newX = this.scrollX + deltaX;// - this.minusX;\r
369         newY = this.scrollY + deltaY;// - this.minusY;\r
370 \r
371         // Slow down if outside of the boundaries\r
372         if( 0 < newX || newX < this.scrollXMax ){\r
373                 newX = this.bounceEnabled ? this.scrollX + ( deltaX ) / 3 : 0 < newX ? 0 : this.scrollXMax;\r
374         };\r
375         \r
376         if( 0 < newY || newY < this.scrollYMax ){\r
377                 //console.log( 'slow... ' + newY + ' ' + this.scrollYMax );\r
378                 newY = this.bounceEnabled ? this.scrollY + ( deltaY ) / 3 : 0 < newY ? 0 : this.scrollYMax;\r
379         };\r
380 \r
381         this.directionX = 0 < deltaX ? -1 : deltaX < 0 ? 1 : 0;\r
382         this.directionY = 0 < deltaY ? -1 : deltaY < 0 ? 1 : 0;\r
383 \r
384         //console.log( 'mov2 x:' + newX + ' y:' + newY );\r
385         X_UI_ScrollBox_translate( this, newX, newY, 0, '', 300 );\r
386 \r
387         if( 300 < timestamp - this.startTime ){\r
388                 this.startTime = timestamp;\r
389                 this.startX = this.scrollX;\r
390                 this.startY = this.scrollY;\r
391         };\r
392         // イベントの拘束\r
393         return ret | X_Callback_PREVENT_DEFAULT | X_Callback_CAPTURE_POINTER;\r
394 };\r
395 \r
396 function X_UI_ScrollBox_onEnd( e ){\r
397         var ret    = X_Callback_NONE,\r
398                 time   = 0,\r
399                 easing = '',\r
400                 newX, newY,\r
401                 momentumX, momentumY,\r
402                 duration, distanceX, distanceY;\r
403                                                 \r
404         this[ 'unlisten' ]( XUI_Event._POINTER_MOVE, this, X_UI_ScrollBox_onMove );\r
405         this[ 'unlisten' ]( [ XUI_Event._POINTER_UP, XUI_Event._POINTER_CANCEL ], this, X_UI_ScrollBox_onEnd );\r
406         \r
407         if( !this.scrollEnabled || e.pointerType !== this.initiated ){\r
408                 return ret;\r
409         };\r
410 \r
411         delete this.isInTransition;\r
412         delete this.initiated;\r
413         this.endTime = X_Timer_now();                   \r
414 \r
415         duration  = this.endTime - this.startTime;\r
416         newX      = Math.round( this.scrollX );\r
417         newY      = Math.round( this.scrollY );\r
418         distanceX = Math.abs(newX - this.startX);\r
419         distanceY = Math.abs(newY - this.startY);\r
420 \r
421         // reset if we are outside of the boundaries\r
422         if( X_UI_ScrollBox_resetPosition( this, this.bounceTime ) ){\r
423                 return ret;\r
424         };\r
425 \r
426         // we scrolled less than 10 pixels\r
427         if( !this.moved ){\r
428                 // this[ 'dispatch' ]( X_EVENT_CANCELED );\r
429                 console.log( 'we scrolled less than 10 pixels ' + e.pageY );\r
430                 return ret;\r
431         };\r
432 \r
433         // start momentum animation if needed\r
434         if( this.momentumEnabled && duration < 300 ){\r
435                 momentumX = this.hasHScroll ?\r
436                                                 X_UI_ScrollBox_momentum( this.scrollX, this.startX, duration, this.scrollXMax, this.bounceEnabled ? this.boxWidth  * this.fontSize : 0, this.deceleration ) :\r
437                                                 { destination: newX, duration: 0 };\r
438                 momentumY = this.hasVScroll   ?\r
439                                                 X_UI_ScrollBox_momentum( this.scrollY, this.startY, duration, this.scrollYMax, this.bounceEnabled ? this.boxHeight * this.fontSize : 0, this.deceleration ) :\r
440                                                 { destination: newY, duration: 0 };\r
441                 newX = momentumX.destination;\r
442                 newY = momentumY.destination;\r
443                 time = Math.max( momentumX.duration, momentumY.duration ) | 0;\r
444                 this.isInTransition = true;\r
445         } else {\r
446                 console.log( '慣性無し' );\r
447         };\r
448 \r
449         if( newX != this.scrollX || newY != this.scrollY ){\r
450                 // change easing function when scroller goes out of the boundaries\r
451                 if( 0 < newX || newX < this.scrollXMax || 0 < newY || newY < this.scrollYMax ){\r
452                         easing = 'quadratic';\r
453                 };\r
454 \r
455                 console.log( 'end2 x:' + newX + ' y:' + newY + ' t:' + time );\r
456                 this.scrollTo( newX, newY, time, easing, 1000 );\r
457                 return ret;\r
458         };\r
459 \r
460         console.log( 'end1 x:' + newX + ' y:' + newY );\r
461         this.scrollTo( newX, newY, 0, '', 1000 );       // ensures that the last position is rounded\r
462 \r
463         this[ 'dispatch' ]( XUI_Event.SCROLL_END );\r
464         \r
465         return ret;\r
466 };\r
467 \r
468 function X_UI_ScrollBox_resetPosition( that, time ){\r
469         var x = that.scrollX,\r
470                 y = that.scrollY;\r
471 \r
472         time = time || 0;\r
473 \r
474         if( !that.hasHScroll || 0 < that.scrollX ){\r
475                 x = 0;\r
476         } else\r
477         if( that.scrollX < that.scrollXMax ){\r
478                 x = that.scrollXMax;\r
479         };\r
480 \r
481         if( !that.hasVScroll || 0 < that.scrollY ){\r
482                 y = 0;\r
483         } else\r
484         if( that.scrollY < that.scrollYMax ){\r
485                 y = that.scrollYMax;\r
486         };\r
487 \r
488         if( x === that.scrollX && y === that.scrollY ){\r
489                 console.log( 'no バウンド y:' + y + ' max:' + that.scrollYMax );\r
490                 return false;\r
491         };\r
492 \r
493         //console.log( 'バウンド!' );\r
494         //console.log( 'rese x:' + x + ' y:' + y );\r
495         that.scrollTo( x, y, time, that.bounceEasing, 1000 );\r
496 \r
497         return true;\r
498 };\r
499 \r
500 function X_UI_ScrollBox_onAnimeEnd( e ){\r
501         if( e.target !== this.xnodeSlider || !this.isInTransition ){\r
502                 return X_Callback_NONE;\r
503         };\r
504         if( !X_UI_ScrollBox_resetPosition( this, this.bounceTime ) ){\r
505                 this.isInTransition = false;\r
506                 this.dispatch( XUI_Event.SCROLL_END );\r
507         };\r
508         return X_Callback_NONE;\r
509 };\r
510 \r
511 X.UI.ScrollBox = X.UI.ChromeBox.inherits(\r
512         'ScrollBox',\r
513         X_Class.NONE,\r
514         XUI_ScrollBox,\r
515         {\r
516                 Constructor : function(){\r
517                         var args = [\r
518                                                 XUI_Layout_Vertical,                    \r
519                                                 {\r
520                                                         name   : 'ScrollBox-Scroller',\r
521                                                         role   : 'container',\r
522                                                         width       : 'auto',\r
523                                                         minWidth    : '100%',\r
524                                                         height      : 'auto',\r
525                                                         minHeight   : '100%'\r
526                                                 }\r
527                                         ],\r
528                                 i    = arguments.length,\r
529                                 arg, layout, attr;\r
530                         \r
531                         for( ; i; ){\r
532                                 arg = arguments[ --i ];\r
533                                 if( arg[ 'instanceOf' ] && arg[ 'instanceOf' ]( XUI_LayoutBase ) ){\r
534                                         layout = arg;\r
535                                 } else\r
536                                 if( arg[ 'instanceOf' ] && arg[ 'instanceOf' ]( X.UI.AbstractUINode ) ){\r
537                                         args[ args.length ] = arg;\r
538                                 } else\r
539                                 if( X_Type_isObject( arg ) ){\r
540                                         attr = arg;\r
541                                 };\r
542                         };\r
543                         \r
544                         X_Class_newPrivate(\r
545                                 this,\r
546                                 XUI_Layout_Canvas,\r
547                                 [\r
548                                         {\r
549                                                 width  : '100%',\r
550                                                 height : '100%'\r
551                                         },\r
552                                         X.UI.VBox.apply( 0, args )\r
553                                 ]\r
554                         );\r
555                         \r
556                         attr && this.attr( attr );\r
557                 },\r
558                 scrollX  : function(){\r
559                         \r
560                 },\r
561                 scrollY  : function(){\r
562                         \r
563                 },\r
564                 scrollWidth : function(){\r
565                         \r
566                 },\r
567                 scrollHeight : function(){\r
568                         \r
569                 },\r
570                 scrollTo : function( nodeOrX, y ){\r
571                         \r
572                 }\r
573         }\r
574 );