OSDN Git Service

5e49890b668810226afc62a0017fc1482b257081
[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                 isInTransition  : false,\r
44 \r
45                 hasHScroll      : false,\r
46                 hasVScroll      : false,\r
47 \r
48                 wrapperOffset   : 0,\r
49                 wheelTimeout    : 0,\r
50                 requestFrameID  : 0,\r
51                 \r
52                 fontSize        : 0,\r
53                 \r
54                 scrollX         : 0, // px\r
55                 scrollY         : 0, // px\r
56                 scrollXMax      : 0, // px\r
57                 scrollYMax      : 0, // px\r
58                 scrollXRatio    : 0, // この値は scroll 不要になっても保持される。 scroll 必要時に参照される\r
59                 scrollYRatio    : 0,            \r
60                 startX          : 0, // px\r
61                 startY          : 0, // px\r
62                 absStartX       : 0, // px\r
63                 absStartY       : 0, // px\r
64                 pointX          : 0, // px\r
65                 pointY          : 0, // px\r
66                 distX               : 0, // px\r
67                 distY               : 0, // px\r
68                 directionX      : 0, // -1, 0, 1\r
69                 directionY      : 0, // -1, 0, 1\r
70                 \r
71                 lastScrollWidth  : 0,\r
72                 lastScrollHeight : 0,\r
73                 lastBoxWidth     : 0,\r
74                 lastBoxHeight    : 0,\r
75                 \r
76                 _containerNode   : null,\r
77                 xnodeSlider      : null,\r
78                 \r
79                 Constructor : function( user, layout, args ){\r
80                         this[ 'Super' ]( user, layout, args );\r
81                         this._containerNode = X_Pair_get( this.containerNode );\r
82                         this.xnodeSlider = this._containerNode.xnode[ 'className' ]( 'ScrollSlider' ).listen( X_EVENT_ANIME_END, this, X_UI_ScrollBox_onAnimeEnd );\r
83                         this.xnode[ 'className' ]( 'ScrollBox' );\r
84                 },\r
85                 \r
86                 creationComplete : function(){\r
87                         XUI_Box.prototype.creationComplete.apply( this, arguments );\r
88                 },\r
89                 \r
90                 calculate : function(){\r
91                         this.lastScrollWidth  = this._containerNode.boxWidth;\r
92                         this.lastScrollHeight = this._containerNode.boxHeight;\r
93                         this.lastBoxWidth     = this.boxWidth;\r
94                         this.lastBoxHeight    = this.boxHeight;\r
95                         \r
96                         XUI_Box.prototype.calculate.apply( this, arguments );\r
97                         \r
98                         // TODO root の layout_complete 後に。\r
99                         // TODO calculate 前に scroll の解放。\r
100                         \r
101                         if(\r
102                                         this.lastScrollWidth  !== this._containerNode.boxWidth ||\r
103                                         this.lastScrollHeight !== this._containerNode.boxHeight ||\r
104                                         this.lastBoxWidth    !== this.boxWidth    || this.lastBoxHeight    !== this.boxHeight\r
105                                 ){\r
106                                         X_UI_rootData[ 'listenOnce' ]( XUI_Event.LAYOUT_COMPLETE, this, X_UI_ScrollBox_onLayoutComplete );\r
107                                 };\r
108                 },\r
109         \r
110                 scrollTo : function( x, y, opt_time, opt_easing, opt_release ){\r
111                         //if( this.scrollX === x && this.scrollY === y ) return;\r
112                         \r
113                         opt_time    = 0 <= opt_time ? opt_time : 0;\r
114                         opt_easing  = opt_easing || 'circular';\r
115                         opt_release = 0 <= opt_release ? opt_release : 300;\r
116         \r
117                         this.isInTransition = 0 < opt_time;\r
118         \r
119                         X_UI_ScrollBox_translate( this, x, y, opt_time, opt_easing, opt_release );\r
120                 },\r
121                 \r
122                 _remove : function(){\r
123                         XUI_AbstractUINode.prototype._remove.apply( this, arguments );\r
124                         if( this.scrolling ){\r
125                                 // remove scroll\r
126                         };\r
127                 }\r
128                 \r
129         }\r
130 );\r
131 \r
132 function X_UI_ScrollBox_onLayoutBefore( e ){\r
133         if( e[ 'cancelable' ] && this.isInTransition && X_Node_Anime_translateZ ){\r
134                 this[ 'listenOnce' ]( XUI_Event.SCROLL_END, X_UI_rootData, X_UI_rootData.calculate );\r
135                 return X_CALLBACK_PREVENT_DEFAULT;\r
136         };\r
137         this.scrollXRatio = this.scrollX ? this.scrollXMax / this.scrollX : 0;\r
138         this.scrollYRatio = this.scrollY ? this.scrollYMax / this.scrollY : 0;\r
139         this.xnodeSlider.stop();\r
140         this.isInTransition = false;\r
141         return X_CALLBACK_NONE;\r
142 };\r
143 \r
144 function X_UI_ScrollBox_onLayoutComplete( e ){\r
145         // scroll の停止、GPU の解除\r
146         var font = this.fontSize = this.xnodeSlider.call( 'fontSize' );\r
147 \r
148         this.scrollXMax = ( this.boxWidth  - this._containerNode.boxWidth )  * font | 0;\r
149         this.scrollYMax = ( this.boxHeight - this._containerNode.boxHeight ) * font | 0;\r
150 \r
151         this.hasHScroll = this.scrollXEnabled && ( this.scrollXMax < -1 ); // < 0 だと \r
152         this.hasVScroll = this.scrollYEnabled && ( this.scrollYMax < -1 );\r
153 \r
154         if( !this.hasHScroll ){\r
155                 this.scrollXMax  = 0;\r
156         };\r
157 \r
158         if( !this.hasVScroll ){\r
159                 this.scrollYMax   = 0;\r
160         };\r
161 \r
162         delete this.endTime;\r
163         delete this.directionX;\r
164         delete this.directionY;\r
165 \r
166         X_UI_ScrollBox_resetPosition( this, 0 );\r
167 \r
168         if( this.hasHScroll || this.hasVScroll ){\r
169                 // scroll が必要。\r
170                 if( this.scrolling ){\r
171                         X_UI_ScrollBox_translate( this, this.scrollXMax * this.scrollXRatio, this.scrollYMax * this.scrollYRatio, 100, '', 300 );\r
172                 } else {\r
173                         // scroller 作る\r
174                         this[ 'listen' ]( XUI_Event._POINTER_DOWN, this, X_UI_ScrollBox_onStart );\r
175                         X_UI_rootData[ 'listen' ]( XUI_Event.LAYOUT_BEFORE, this, X_UI_ScrollBox_onLayoutBefore );\r
176                         \r
177                         X_UI_ScrollBox_translate( this, this.scrollXMax * this.scrollXRatio, this.scrollYMax * this.scrollYRatio, 100, '', 300 );\r
178                         this.scrolling = true;\r
179                 };\r
180         } else\r
181         // scroll 不要\r
182         if( this.scrolling ){\r
183                 // scroller 削除\r
184                 this[ 'unlisten' ]( XUI_Event._POINTER_DOWN, this, X_UI_ScrollBox_onStart );\r
185                 X_UI_rootData[ 'unlisten' ]( XUI_Event.LAYOUT_BEFORE,   this, X_UI_ScrollBox_onLayoutBefore );\r
186                 \r
187                 ( this.scrollX !== 0 || this.scrollY !== 0 ) && X_UI_ScrollBox_translate( this, 0, 0, 100, '', 300 );\r
188                 \r
189                 delete this.scrolling;\r
190                 delete this.scrollXRatio;\r
191                 delete this.scrollYRatio;\r
192         };\r
193 };\r
194 \r
195                 // TODO use scrollLeft, scrollTop\r
196                 function X_UI_ScrollBox_translate( that, x, y, opt_time, opt_easing, opt_release ){\r
197                         \r
198                         opt_time    = 0 <= opt_time ? opt_time : 0;\r
199                         opt_easing  = opt_easing === '' ? '' : opt_easing || 'circular';\r
200                         opt_release = 0 <= opt_release ? opt_release : 300;\r
201                         \r
202                         that.xnodeSlider.animate(\r
203                                 {\r
204                                         x : that.scrollX,\r
205                                         y : that.scrollY\r
206                                 },\r
207                                 {\r
208                                         x : x,\r
209                                         y : y\r
210                                 },\r
211                                 opt_time, opt_easing, opt_release\r
212                         );\r
213                         \r
214                         that.scrollX = x;\r
215                         that.scrollY = y;\r
216                         \r
217                         if( that.indicators ){\r
218                                 for( i = that.indicators.length; i--; ){\r
219                                         that.indicators[ i ].updatePosition();\r
220                                 };\r
221                         };\r
222                 };\r
223 \r
224 function X_UI_ScrollBox_onStart( e ){\r
225         var ret = X_CALLBACK_NONE;\r
226 \r
227         // React to left mouse button only\r
228         if( e.pointerType === 'mouse' && e.button !== 0 ){\r
229                 return ret;\r
230         };\r
231         \r
232         if( !this.scrollEnabled || ( this.initiated && e.pointerType !== this.initiated ) ){\r
233                 return ret;\r
234         };\r
235 \r
236         this.initiated       = e.pointerType;\r
237         this.moved                   = false;\r
238         this.distX                   = 0;\r
239         this.distY                   = 0;\r
240         this.directionX      = 0;\r
241         this.directionY      = 0;\r
242         this.directionLocked = '';\r
243         this.startTime       = X_Timer_now();\r
244 \r
245         // スクロール中の停止\r
246         if( this.isInTransition ){\r
247                 this.isInTransition = false;\r
248                 this[ 'dispatch' ]( XUI_Event.SCROLL_END );\r
249                 // TODO current位置\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( ' ===> resetPosition - バウンド!' );\r
467         console.log( '      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 X.UI.ScrollBox = X.UI.ChromeBox.inherits(\r
513         'ScrollBox',\r
514         X_Class.NONE,\r
515         {\r
516                 Constructor : function(){\r
517                         var supports, slider;\r
518                         \r
519                         if( XUI_ScrollBox.prototype.usableAttrs === XUI_ChromeBox.prototype.usableAttrs ){\r
520                                 XUI_ScrollBox.prototype.usableAttrs = supports = XUI_Attr_createAttrDef( XUI_Attr_Support, X_UI_ScrollBox_SUPPORT_ATTRS );\r
521                 \r
522                                 XUI_ScrollBox.prototype.attrClass   = XUI_Attr_preset( XUI_Box.prototype.attrClass, supports, { width  : '100%', height : '100%', bgColor : 0x111111 } );\r
523                         };\r
524                         \r
525                         var args = [\r
526                                                 XUI_Layout_Vertical,                    \r
527                                                 {\r
528                                                         name      : 'ScrollBox-Scroller',\r
529                                                         role      : 'container',\r
530                                                         width     : 'auto',\r
531                                                         minWidth  : '100%',\r
532                                                         height    : 'auto',\r
533                                                         minHeight : '100%'\r
534                                                 }\r
535                                         ],\r
536                                 i    = arguments.length,\r
537                                 arg, attr;\r
538                         \r
539                         for( ; i; ){\r
540                                 arg = arguments[ --i ];\r
541                                 if( arg[ 'instanceOf' ] && arg[ 'instanceOf' ]( XUI_LayoutBase ) ){\r
542                                         args[ 0 ] = arg;\r
543                                 } else\r
544                                 if( arg[ 'instanceOf' ] && arg[ 'instanceOf' ]( X.UI.AbstractUINode ) ){\r
545                                         args[ args.length ] = arg;\r
546                                 } else\r
547                                 if( X_Type_isObject( arg ) ){\r
548                                         args[ args.length ] = attr = arg;\r
549                                         slider = attr.scrollSlider;\r
550                                 };\r
551                         };\r
552                         \r
553                         X_Pair_create(\r
554                                 this,\r
555                                 XUI_ScrollBox(\r
556                                         this,\r
557                                         null,\r
558                                         [\r
559                                                 slider || X.UI.VBox.apply( 0, args )\r
560                                         ]\r
561                                 )\r
562                         );\r
563                         \r
564                         //attr && this.attr( attr );\r
565                 },\r
566                 scrollX  : function(){\r
567                         \r
568                 },\r
569                 scrollY  : function(){\r
570                         \r
571                 },\r
572                 scrollWidth : function(){\r
573                         \r
574                 },\r
575                 scrollHeight : function(){\r
576                         \r
577                 },\r
578                 scrollTo : function( nodeOrX, y ){\r
579                         \r
580                 }\r
581         }\r
582 );\r
583 \r