1. Introduction
The Uize.Widget.Bar.Slider class implements a slider widget that lets the user select a value by clicking-and-dragging the slider knob along a track.
DEVELOPERS: Chris van Rensburg
The Uize.Widget.Bar.Slider module defines the Uize.Widget.Bar.Slider widget class, a subclass of Uize.Widget.Bar. With the Uize.Widget.Bar superclass, the knob implied node acts purely as a value indicator, but with the Uize.Widget.Bar.Slider class, the knob is draggable by the user.
2. Instance Events
2.1. Value Change After Rest
The Value Change After Rest event is similar to the Changed.value event, except that it is only fired during drag if the slider's knob has rested on the same value for the amount of time specified by the restTime set-get property.
When a slider is not in drag mode, then the Value Change After Rest event fires every time the Changed.value event fires. The Value Change After Rest event also fires immediately upon releasing the slider's knob if the value has changed since the previous firing of the event (a user may in some cases release a knob after resting it for long enough to have this event fire, in which case this event will not fire again upon release).
This event is useful when wiring up sliders to drive updates that might be costly, such as complex changes to the DOM or updates that require requests to a server. In these cases, wiring into the Value Change After Rest event lets you conveniently tune how rapid-fire the costly updates are.
3. Set-get Properties
3.1. inDrag
A boolean value, indicating whether or not the slider's knob is being dragged by the user.
To monitor when a slider is being dragged, one can register an event handler on the Changed.inDrag instance event.
NOTES
the initial value is false | |
| this property is read-only |
3.2. restTime
An integer, representing the time (in milliseconds) that the user must rest the mouse - during dragging the slider's knob - before the Value Change After Rest instance event will be fired.
Using this property in conjunction with the Value Change After Rest instance event is useful in triggering updates that would be too expensive to trigger continuously during a drag operation.
NOTES
the initial value is 250 |
3.3. valueFunc
An optional function that can be provided to achieve a non-linear transformation of the slider's knob position to a value for the instance's value set-get property.
This property should be used in conjunction with the scaleFunc set-get property. In order for the slider to operate sensibly, any function specified for this property should be the inverse of a function specified for the scaleFunc property. For example, if the function function (unscaled) {return Math.pow (unscaled)} was specified for the scaleFunc property, then the function function (scaled) {return Math.sqrt (scaled)} should be specified for the valueFunc property.
NOTES
| the initial value is a function that has no effect |