1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-slider.Single'>/**
2 </span> * @class Ext.slider.Single
3 * @extends Ext.slider.Multi
4 * Slider which supports vertical or horizontal orientation, keyboard adjustments,
5 * configurable snapping, axis clicking and animation. Can be added as an item to
7 * {@img Ext.slider.Single/Ext.slider.Single.png Ext.slider.Single component}
9 <pre><code>
10 Ext.create('Ext.slider.Single', {
16 renderTo: Ext.getBody()
18 </code></pre>
19 * The class Ext.slider.Single is aliased to Ext.Slider for backwards compatibility.
22 Ext.define('Ext.slider.Single', {
23 extend: 'Ext.slider.Multi',
24 alias: ['widget.slider', 'widget.sliderfield'],
25 alternateClassName: ['Ext.Slider', 'Ext.form.SliderField', 'Ext.slider.SingleSlider', 'Ext.slider.Slider'],
27 <span id='Ext-slider.Single-method-getValue'> /**
28 </span> * Returns the current value of the slider
29 * @return {Number} The current value of the slider
31 getValue: function() {
32 //just returns the value of the first thumb, which should be the only one in a single slider
33 return this.callParent([0]);
36 <span id='Ext-slider.Single-method-setValue'> /**
37 </span> * Programmatically sets the value of the Slider. Ensures that the value is constrained within
38 * the minValue and maxValue.
39 * @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)
40 * @param {Boolean} animate Turn on or off animation, defaults to true
42 setValue: function(value, animate) {
43 var args = Ext.toArray(arguments),
46 //this is to maintain backwards compatiblity for sliders with only one thunb. Usually you must pass the thumb
47 //index to setValue, but if we only have one thumb we inject the index here first if given the multi-slider
48 //signature without the required index. The index will always be 0 for a single slider
49 if (len == 1 || (len <= 3 && typeof arguments[1] != 'number')) {
53 return this.callParent(args);
57 getNearest : function(){
58 // Since there's only 1 thumb, it's always the nearest
59 return this.thumbs[0];
62 </pre></pre></body></html>