Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / layout / component / field / Slider.js
1 /**
2  * @class Ext.layout.component.field.Slider
3  * @extends Ext.layout.component.field.Field
4  * @private
5  */
6
7 Ext.define('Ext.layout.component.field.Slider', {
8
9     /* Begin Definitions */
10
11     alias: ['layout.sliderfield'],
12
13     extend: 'Ext.layout.component.field.Field',
14
15     /* End Definitions */
16
17     type: 'sliderfield',
18
19     sizeBodyContents: function(width, height) {
20         var owner = this.owner,
21             thumbs = owner.thumbs,
22             length = thumbs.length,
23             inputEl = owner.inputEl,
24             innerEl = owner.innerEl,
25             endEl = owner.endEl,
26             i = 0;
27
28         /*
29          * If we happen to be animating during a resize, the position of the thumb will likely be off
30          * when the animation stops. As such, just stop any animations before syncing the thumbs.
31          */
32         for(; i < length; ++i) {
33             thumbs[i].el.stopAnimation();
34         }
35         
36         if (owner.vertical) {
37             inputEl.setHeight(height);
38             innerEl.setHeight(Ext.isNumber(height) ? height - inputEl.getPadding('t') - endEl.getPadding('b') : height);
39         }
40         else {
41             inputEl.setWidth(width);
42             innerEl.setWidth(Ext.isNumber(width) ? width - inputEl.getPadding('l') - endEl.getPadding('r') : width);
43         }
44         owner.syncThumbs();
45     }
46 });