Class: Slider

Slider()

new Slider()

An interactive UI element for selecting a value within a range by dragging a thumb.
Source:

Extends

  • BaseUIElement

Methods

containsPoint(px, py, rectopt) → {boolean}

Overloaded containsPoint to check against a specific rect (for thumb).
Parameters:
Name Type Attributes Default Description
px number
py number
rect object <optional>
this The rectangle to check against (defaults to the element itself).
Source:
Returns:
Type
boolean

Slider(options)

new Slider(options)

Creates an instance of Slider.
Parameters:
Name Type Description
options object Configuration options for the slider.
Properties
Name Type Attributes Default Description
x number <optional>
0 The x-coordinate.
y number <optional>
0 The y-coordinate.
width number <optional>
200 The length of the slider track for a horizontal slider, or width if vertical.
height number <optional>
20 The thickness of the slider track for a horizontal slider, or height if vertical. (This is for the main clickable area)
minValue number <optional>
0 The minimum value of the slider.
maxValue number <optional>
100 The maximum value of the slider.
currentValue number <optional>
options.minValue The initial value of the slider.
step number <optional>
1 The increment step for the slider's value. Use 0 for continuous.
orientation string <optional>
'horizontal' 'horizontal' or 'vertical'.
trackColor string <optional>
'#555555' Color of the slider track.
thumbColor string <optional>
'dodgerblue' Color of the slider thumb.
hoverThumbColor string <optional>
'deepskyblue' Color of the thumb when hovered.
pressedThumbColor string <optional>
'royalblue' Color of the thumb when pressed/dragged.
thumbWidth number <optional>
10 Width of the thumb for a horizontal slider.
thumbHeight number <optional>
20 Height of the thumb for a horizontal slider. (Should be >= track height)
showValueText boolean <optional>
false Whether to display the current value as text.
valueTextFont string <optional>
'12px sans-serif' Font for the value text.
valueTextColor string <optional>
'white' Color for the value text.
valueTextFormatFunction function <optional>
Formats the value text. Receives (currentValue).
onValueChanged function <optional>
Callback when the value changes. Receives (newValue).
visible boolean <optional>
true
enabled boolean <optional>
true
id string <optional>
Source:

Methods

containsPoint(px, py, rectopt) → {boolean}

Overloaded containsPoint to check against a specific rect (for thumb).
Parameters:
Name Type Attributes Default Description
px number
py number
rect object <optional>
this The rectangle to check against (defaults to the element itself).
Source:
Returns:
Type
boolean