# Yahoo! UI Library

### Slider Widget 2.8.1

Yahoo! UI Library > slider > YAHOO.widget.DualSlider
Search:
Filters Show Private Show Protected Show Deprecated

## Class YAHOO.widget.DualSlider - uses YAHOO.util.EventProvider

A slider with two thumbs, one that represents the min value and the other the max. Actually a composition of two sliders, both with the same background. The constraints for each slider are adjusted dynamically so that the min value of the max slider is equal or greater to the current value of the min slider, and the max value of the min slider is the current value of the max slider. Constructor assumes both thumbs are positioned absolutely at the 0 mark on the background.

### Constructor

YAHOO.widget.DualSlider `( minSlider , maxSlider , range , initVals )`

Parameters:
  `minSlider <Slider>` The Slider instance used for the min value thumb
  `maxSlider <Slider>` The Slider instance used for the max value thumb
  `range <int>` The number of pixels the thumbs may move within
  `initVals <Array>` (optional) [min,max] Initial thumb placement

### Properties

#### activeSlider - `Slider`

The currently active slider (min or max). read only

#### isHoriz - `boolean`

Is the DualSlider oriented horizontally or vertically? read only

#### maxSlider - `Slider`

A slider instance that keeps track of the upper value of the range. read only

#### maxVal - `int`

The current value of the max thumb. read only.

#### minRange - `int`

Pixel distance to maintain between thumbs.
Default Value: 0

#### minSlider - `Slider`

A slider instance that keeps track of the lower value of the range. read only

#### minVal - `int`

The current value of the min thumb. read only.

#### Properties inherited from YAHOO.util.EventProvider:

`__yui_events, __yui_subscribers`

### Methods

#### _bindKeyEvents

`protected void _bindKeyEvents ( )`
Set up the listeners for the keydown and keypress events.

#### _cleanEvent

`private void _cleanEvent ( o , evt )`
Clean up the slideEnd event subscribers array, since each one-time callback will be replaced in the event's subscribers property with null. This will cause memory bloat and loss of performance.

Parameters:
  `o <EventProvider>` object housing the CustomEvent
  `evt <string>` name of the CustomEvent

#### _handleDrag

`private void _handleDrag ( )`
Overrides the onDrag method for both sliders

#### _handleKeyDown

`protected void _handleKeyDown ( e )`
Delegate event handling to the active Slider. See Slider.handleKeyDown.

Parameters:
  `e <Event>` the mousedown DOM event

#### _handleKeyPress

`protected void _handleKeyPress ( e )`
Delegate event handling to the active Slider. See Slider.handleKeyPress.

Parameters:
  `e <Event>` the mousedown DOM event

#### _handleMaxChange

`private void _handleMaxChange ( )`
Executed when the max slider fires the change event

#### _handleMinChange

`private void _handleMinChange ( )`
Executed when the min slider fires the change event

#### _handleMouseDown

`protected void _handleMouseDown ( e )`
Delegates the onMouseDown to the appropriate Slider

Parameters:
  `e <Event>` mouseup event

#### _handleMouseUp

`protected void _handleMouseUp ( e )`
Delegates the onMouseUp to the active Slider

Parameters:
  `e <Event>` mouseup event

#### _handleSlideEnd

`private void _handleSlideEnd ( )`
Executed when one of the sliders fires the slideEnd event

#### _handleSlideStart

`private void _handleSlideStart ( )`
Executed when one of the sliders fires the slideStart event

#### _oneTimeCallback

`private void _oneTimeCallback ( o , evt , fn )`
Schedule an event callback that will execute once, then unsubscribe itself.

Parameters:
  `o <EventProvider>` Object to attach the event to
  `evt <string>` Name of the event
  `fn <Function>` function to execute once

#### selectActiveSlider

`private void selectActiveSlider ( e )`
A background click will move the slider thumb nearest to the click. Override if you need different behavior.

Parameters:
  `e <Event>` the mousedown event

#### setMaxValue

`void setMaxValue ( max , skipAnim , force , silent )`
Set the max thumb position to a new value.

Parameters:
  `max <int>` Pixel offset for max thumb
  `skipAnim <boolean>` (optional) Set to true to skip thumb animation. Default false
  `force <boolean>` (optional) ignore the locked setting and set value anyway. Default false
  `silent <boolean>` (optional) Set to true to skip firing change events. Default false

#### setMinValue

`void setMinValue ( min , skipAnim , force , silent )`
Set the min thumb position to a new value.

Parameters:
  `min <int>` Pixel offset for min thumb
  `skipAnim <boolean>` (optional) Set to true to skip thumb animation. Default false
  `force <boolean>` (optional) ignore the locked setting and set value anyway. Default false
  `silent <boolean>` (optional) Set to true to skip firing change events. Default false

#### setValues

`void setValues ( min , max , skipAnim , force , silent )`
Sets the min and max thumbs to new values.

Parameters:
  `min <int>` Pixel offset to assign to the min thumb
  `max <int>` Pixel offset to assign to the max thumb
  `skipAnim <boolean>` (optional) Set to true to skip thumb animation. Default false
  `force <boolean>` (optional) ignore the locked setting and set value anyway. Default false
  `silent <boolean>` (optional) Set to true to skip firing change events. Default false

#### updateValue

`private void updateValue ( silent )`
Executed when one of the sliders is moved

Parameters:
  `silent <boolean>` (optional) Set to true to skip firing change events. Default false

#### Methods inherited from YAHOO.util.EventProvider:

`createEvent, fireEvent, hasEvent, subscribe, unsubscribe, unsubscribeAll`

### Events

#### change

`change ( dualslider )`
Event that fires when either the min or max value changes

Parameters:
  `dualslider <DualSlider>` the DualSlider instance

#### ready

`ready ( dualslider )`
Event that fires when the slider is finished setting up

Parameters:
  `dualslider <DualSlider>` the DualSlider instance

#### slideEnd

`slideEnd ( activeSlider )`
Event that fires when one of the thumbs finishes moving

Parameters:
  `activeSlider <Slider>` the moving slider

#### slideStart

`slideStart ( activeSlider )`
Event that fires when one of the thumbs begins to move

Parameters:
  `activeSlider <Slider>` the moving slider

Copyright © 2010 Yahoo! Inc. All rights reserved.