OSDN Git Service

43b57cfabdbe988c2fbaa145b2a133c4960543c6
[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         this[ 'listen' ]( XUI_Event._POINTER_MOVE, this, X_UI_ScrollBox_onMove );\r
288         this[ 'listen' ]( [ XUI_Event._POINTER_UP, XUI_Event._POINTER_CANCEL ], this, X_UI_ScrollBox_onEnd );\r
289 \r
290         return ret | X_Callback_PREVENT_DEFAULT;\r
291 };\r
292 \r
293 function X_UI_ScrollBox_onMove( e ){\r
294         var ret = X_Callback_NONE,\r
295                 deltaX, deltaY, timestamp,\r
296                 newX, newY,\r
297                 absDistX, absDistY;\r
298         // 規定以上の move でスクロール開始\r
299         \r
300         if( !this.scrollEnabled || e.pointerType !== this.initiated ){\r
301                 return ret;\r
302         };\r
303         \r
304         if( e.buttons !== 1 ){\r
305                 return X_UI_ScrollBox_onEnd.call( this, e );\r
306         };\r
307 \r
308         // gpu の用意\r
309         if( !this.xnodeSlider[ '_anime' ] ){\r
310                 //console.log( 'gpuレイヤーの用意 ' + e.pageY );\r
311                 //console.log( 'mov1 x:' + this.scrollX + ' y:' + this.scrollY );\r
312                 X_UI_ScrollBox_translate( this, this.scrollX, this.scrollY, 0, '', 300 );\r
313                 return ret;\r
314         };\r
315 \r
316         deltaX          = e.pageX - this.pointX;\r
317         deltaY          = e.pageY - this.pointY;\r
318         timestamp       = X_Timer_now();\r
319 \r
320         this.pointX     = e.pageX;\r
321         this.pointY     = e.pageY;\r
322 \r
323         this.distX      += deltaX;\r
324         this.distY      += deltaY;\r
325         absDistX        = Math.abs(this.distX);\r
326         absDistY        = Math.abs(this.distY);\r
327         \r
328         // We need to move at least 10 pixels for the scrolling to initiate\r
329         if( 300 < timestamp - this.endTime && ( absDistX < 10 && absDistY < 10 ) ){\r
330                 return ret;\r
331         };\r
332 \r
333         // If you are scrolling in one direction lock the other\r
334         if( !this.directionLocked ){\r
335                 if( absDistX > absDistY + this.directionLockThreshold ){\r
336                         this.directionLocked = 'h';             // lock horizontally\r
337                 } else\r
338                 if( absDistY >= absDistX + this.directionLockThreshold ){\r
339                         this.directionLocked = 'v';             // lock vertically\r
340                 } else {\r
341                         this.directionLocked = 'n';             // no lock\r
342                 };\r
343         };\r
344 \r
345         if( this.directionLocked === 'h' ){\r
346                 deltaY = 0;\r
347         } else\r
348         if( this.directionLocked === 'v' ){\r
349                 deltaX = 0;\r
350         };\r
351 \r
352         deltaX = this.hasHScroll ? deltaX : 0;\r
353         deltaY = this.hasVScroll ? deltaY : 0;\r
354 \r
355         if( !this.moved ){\r
356                 this[ 'dispatch' ]( XUI_Event.SCROLL_BEFORE_MOVE );\r
357                 this.moved  = true;\r
358                 this.minusX = deltaX;\r
359                 this.minusY = deltaY;\r
360         } else {\r
361                 this[ 'dispatch' ]( XUI_Event.SCROLL_MOVE );\r
362         };\r
363 \r
364         newX = this.scrollX + deltaX;// - this.minusX;\r
365         newY = this.scrollY + deltaY;// - this.minusY;\r
366 \r
367         // Slow down if outside of the boundaries\r
368         if( 0 < newX || newX < this.scrollXMax ){\r
369                 newX = this.bounceEnabled ? this.scrollX + ( deltaX ) / 3 : 0 < newX ? 0 : this.scrollXMax;\r
370         };\r
371         \r
372         if( 0 < newY || newY < this.scrollYMax ){\r
373                 //console.log( 'slow... ' + newY + ' ' + this.scrollYMax );\r
374                 newY = this.bounceEnabled ? this.scrollY + ( deltaY ) / 3 : 0 < newY ? 0 : this.scrollYMax;\r
375         };\r
376 \r
377         this.directionX = 0 < deltaX ? -1 : deltaX < 0 ? 1 : 0;\r
378         this.directionY = 0 < deltaY ? -1 : deltaY < 0 ? 1 : 0;\r
379 \r
380         //console.log( 'mov2 x:' + newX + ' y:' + newY );\r
381         X_UI_ScrollBox_translate( this, newX, newY, 0, '', 300 );\r
382 \r
383         if( 300 < timestamp - this.startTime ){\r
384                 this.startTime = timestamp;\r
385                 this.startX = this.scrollX;\r
386                 this.startY = this.scrollY;\r
387         };\r
388         // イベントの拘束\r
389         return ret | X_Callback_PREVENT_DEFAULT | X_Callback_CAPTURE_POINTER;\r
390 };\r
391 \r
392 function X_UI_ScrollBox_onEnd( e ){\r
393         var ret    = X_Callback_NONE,\r
394                 time   = 0,\r
395                 easing = '',\r
396                 newX, newY,\r
397                 momentumX, momentumY,\r
398                 duration, distanceX, distanceY;\r
399                                                 \r
400         this[ 'unlisten' ]( XUI_Event._POINTER_MOVE, this, X_UI_ScrollBox_onMove );\r
401         this[ 'unlisten' ]( [ XUI_Event._POINTER_UP, XUI_Event._POINTER_CANCEL ], this, X_UI_ScrollBox_onEnd );\r
402         \r
403         if( !this.scrollEnabled || e.pointerType !== this.initiated ){\r
404                 return ret;\r
405         };\r
406 \r
407         delete this.isInTransition;\r
408         delete this.initiated;\r
409         this.endTime = X_Timer_now();                   \r
410 \r
411         duration  = this.endTime - this.startTime;\r
412         newX      = Math.round( this.scrollX );\r
413         newY      = Math.round( this.scrollY );\r
414         distanceX = Math.abs(newX - this.startX);\r
415         distanceY = Math.abs(newY - this.startY);\r
416 \r
417         // reset if we are outside of the boundaries\r
418         if( X_UI_ScrollBox_resetPosition( this, this.bounceTime ) ){\r
419                 return ret;\r
420         };\r
421 \r
422         // we scrolled less than 10 pixels\r
423         if( !this.moved ){\r
424                 // this[ 'dispatch' ]( X_EVENT_CANCELED );\r
425                 console.log( 'we scrolled less than 10 pixels' );\r
426                 return ret;\r
427         };\r
428 \r
429         // start momentum animation if needed\r
430         if( this.momentumEnabled && duration < 300 ){\r
431                 momentumX = this.hasHScroll ?\r
432                                                 X_UI_ScrollBox_momentum( this.scrollX, this.startX, duration, this.scrollXMax, this.bounceEnabled ? this.boxWidth  * this.fontSize : 0, this.deceleration ) :\r
433                                                 { destination: newX, duration: 0 };\r
434                 momentumY = this.hasVScroll   ?\r
435                                                 X_UI_ScrollBox_momentum( this.scrollY, this.startY, duration, this.scrollYMax, this.bounceEnabled ? this.boxHeight * this.fontSize : 0, this.deceleration ) :\r
436                                                 { destination: newY, duration: 0 };\r
437                 newX = momentumX.destination;\r
438                 newY = momentumY.destination;\r
439                 time = Math.max( momentumX.duration, momentumY.duration ) | 0;\r
440                 this.isInTransition = true;\r
441         } else {\r
442                 console.log( '慣性無し' );\r
443         };\r
444 \r
445         if( newX != this.scrollX || newY != this.scrollY ){\r
446                 // change easing function when scroller goes out of the boundaries\r
447                 if( 0 < newX || newX < this.scrollXMax || 0 < newY || newY < this.scrollYMax ){\r
448                         easing = 'quadratic';\r
449                 };\r
450 \r
451                 console.log( 'end2 x:' + newX + ' y:' + newY + ' t:' + time );\r
452                 this.scrollTo( newX, newY, time, easing, 1000 );\r
453                 return ret;\r
454         };\r
455 \r
456         console.log( 'end1 x:' + newX + ' y:' + newY );\r
457         this.scrollTo( newX, newY, 0, '', 1000 );       // ensures that the last position is rounded\r
458 \r
459         this[ 'dispatch' ]( XUI_Event.SCROLL_END );\r
460         \r
461         return ret;\r
462 };\r
463 \r
464 function X_UI_ScrollBox_resetPosition( that, time ){\r
465         var x = that.scrollX,\r
466                 y = that.scrollY;\r
467 \r
468         time = time || 0;\r
469 \r
470         if( !that.hasHScroll || 0 < that.scrollX ){\r
471                 x = 0;\r
472         } else\r
473         if( that.scrollX < that.scrollXMax ){\r
474                 x = that.scrollXMax;\r
475         };\r
476 \r
477         if( !that.hasVScroll || 0 < that.scrollY ){\r
478                 y = 0;\r
479         } else\r
480         if( that.scrollY < that.scrollYMax ){\r
481                 y = that.scrollYMax;\r
482         };\r
483 \r
484         if( x === that.scrollX && y === that.scrollY ){\r
485                 console.log( 'no バウンド y:' + y + ' max:' + that.scrollYMax );\r
486                 return false;\r
487         };\r
488 \r
489         //console.log( 'バウンド!' );\r
490         //console.log( 'rese x:' + x + ' y:' + y );\r
491         that.scrollTo( x, y, time, that.bounceEasing, 1000 );\r
492 \r
493         return true;\r
494 };\r
495 \r
496 function X_UI_ScrollBox_onAnimeEnd( e ){\r
497         if( e.target !== this.xnodeSlider || !this.isInTransition ){\r
498                 return X_Callback_NONE;\r
499         };\r
500         if( !X_UI_ScrollBox_resetPosition( this, this.bounceTime ) ){\r
501                 this.isInTransition = false;\r
502                 this.dispatch( XUI_Event.SCROLL_END );\r
503         };\r
504         return X_Callback_NONE;\r
505 };\r
506 \r
507 X.UI.ScrollBox = X.UI.ChromeBox.inherits(\r
508         'ScrollBox',\r
509         X_Class.NONE,\r
510         XUI_ScrollBox,\r
511         {\r
512                 Constructor : function(){\r
513                         var args = [\r
514                                                 XUI_Layout_Vertical,                    \r
515                                                 {\r
516                                                         name   : 'ScrollBox-Scroller',\r
517                                                         role   : 'container',\r
518                                                         width       : 'auto',\r
519                                                         minWidth    : '100%',\r
520                                                         height      : 'auto',\r
521                                                         minHeight   : '100%'\r
522                                                 }\r
523                                         ],\r
524                                 i    = arguments.length,\r
525                                 arg, layout, attr;\r
526                         \r
527                         for( ; i; ){\r
528                                 arg = arguments[ --i ];\r
529                                 if( arg[ 'instanceOf' ] && arg[ 'instanceOf' ]( XUI_LayoutBase ) ){\r
530                                         layout = arg;\r
531                                 } else\r
532                                 if( arg[ 'instanceOf' ] && arg[ 'instanceOf' ]( X.UI.AbstractUINode ) ){\r
533                                         args[ args.length ] = arg;\r
534                                 } else\r
535                                 if( X_Type_isObject( arg ) ){\r
536                                         attr = arg;\r
537                                 };\r
538                         };\r
539                         \r
540                         X_Class_newPrivate(\r
541                                 this,\r
542                                 XUI_Layout_Canvas,\r
543                                 [\r
544                                         {\r
545                                                 width  : '100%',\r
546                                                 height : '100%'\r
547                                         },\r
548                                         X.UI.VBox.apply( 0, args )\r
549                                 ]\r
550                         );\r
551                         \r
552                         attr && this.attr( attr );\r
553                 },\r
554                 scrollX  : function(){\r
555                         \r
556                 },\r
557                 scrollY  : function(){\r
558                         \r
559                 },\r
560                 scrollWidth : function(){\r
561                         \r
562                 },\r
563                 scrollHeight : function(){\r
564                         \r
565                 },\r
566                 scrollTo : function( nodeOrX, y ){\r
567                         \r
568                 }\r
569         }\r
570 );