OSDN Git Service

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