Show:

One class of value algorithm that can be built onto SliderBase. By default, values range between 0 and 100, but you can configure these on the built Slider class by setting the <code>min</code> and <code>max</code> configurations. Set the initial value (will cause the thumb to move to the appropriate location on the rail) in configuration as well if appropriate.

Methods

_afterMaxChange

(
  • e
)
protected

Update position according to new max value. If the new max results in the current value being out of range, the value is set to the closer of min or max.

Parameters:

  • e EventFacade

    <p>The <code>max</code> attribute change event.</p>

_afterMinChange

(
  • e
)
protected

Update position according to new min value. If the new min results in the current value being out of range, the value is set to the closer of min or max.

Parameters:

  • e EventFacade

    <p>The <code>min</code> attribute change event.</p>

_afterValueChange

(
  • e
)
protected

Propagate change to the thumb position unless the change originated from the thumbMove event.

Parameters:

  • e EventFacade

    <p>The <code>valueChange</code> event.</p>

_bindValueLogic

() protected

Override of stub method in SliderBase that is called at the end of its bindUI stage of render(). Subscribes to internal events to trigger UI and related state updates.

_calculateFactor

() protected

Calculates and caches (range between max and min) / (rail length) for fast runtime calculation of position -> value.

_defThumbMoveFn

(
  • e
)
protected

Dispatch the new position of the thumb into the value setting operations.

Parameters:

_initSliderValueRange

() protected

Stub for construction logic. Override if extending this class and you need to set something up during the initializer phase.

_nearestValue

(
  • value
)
Number protected

Returns the nearest valid value to the value input. If the provided value is outside the min - max range, accounting for min > max scenarios, the nearest of either min or max is returned. Otherwise, the provided value is returned.

Parameters:

  • value Mixed

    <p>Value to test against current min - max range</p>

Returns:

Number:

<p>Current min, max, or value if within range</p>

_offsetToValue

(
  • offset
)
Mixed protected

<p>Converts a pixel position into a value. Calculates current thumb offset from the leading edge of the rail multiplied by the ratio of <code>(max - min) / (constraining dim)</code>.</p>

<p>Override this if you want to use a different value mapping algorithm.</p>

Parameters:

  • offset Number

    <p>X or Y pixel offset</p>

Returns:

Mixed:

<p>Value corresponding to the provided pixel offset</p>

_setNewValue

(
  • value
)
Number protected

Restricts new values assigned to <code>value</code> attribute to be between the configured <code>min</code> and <code>max</code>. Rounds to nearest integer value.

Parameters:

  • value Number

    <p>Value assigned to <code>value</code> attribute</p>

Returns:

Number:

<p>Normalized and constrained value</p>

_setPosition

(
  • value
  • [options]
)
protected

Positions the thumb and its ARIA attributes in accordance with the translated value.

Parameters:

  • value Number

    <p>Value to translate to a pixel position</p>

  • [options] Object optional

    <p>Details object to pass to <code>_uiMoveThumb</code></p>

_syncThumbPosition

() protected

Move the thumb to appropriate position if necessary. Also resets the cached offsets and recalculates the conversion factor to translate position to value.

_validateNewMax

(
  • value
)
Boolean protected

Validates new values assigned to <code>max</code> attribute. Numbers are acceptable. Override this to enforce different rules.

Parameters:

  • value Mixed

    <p>Value assigned to <code>max</code> attribute.</p>

Returns:

Boolean:

<p>True for numbers. False otherwise.</p>

_validateNewMin

(
  • value
)
Boolean protected

Validates new values assigned to <code>min</code> attribute. Numbers are acceptable. Override this to enforce different rules.

Parameters:

  • value Any

    <p>Value assigned to <code>min</code> attribute.</p>

Returns:

Boolean:

<p>True for numbers. False otherwise.</p>

_valueToOffset

(
  • val
)
Number protected

Converts a value into a pixel offset for use in positioning the thumb according to the reverse of the <code>_offsetToValue( xy )</code> operation.

Parameters:

  • val Number

    <p>The value to map to pixel X or Y position</p>

Returns:

Number:

<p>The pixel offset</p>

_verifyValue

() protected

Verifies that the current value is within the min - max range. If not, value is set to either min or max, depending on which is closer.

getValue

() Number

Returns the current value. Override this if you want to introduce output formatting. Otherwise equivalent to slider.get( "value" );

Returns:

setValue

(
  • val
)
Slider chainable

Updates the current value. Override this if you want to introduce input value parsing or preprocessing. Otherwise equivalent to slider.set( "value", v );

Parameters:

  • val Number

    <p>The new value</p>

Returns:

Properties

_factor

Number protected

Factor used to translate value -> position -> value.

ATTRS

Object protected static

Attributes that will be added onto host class.

Attributes

majorStep

Number

amount to increment/decrement the Slider value when the page up/down keys are pressed

Default: 10

max

Number

The value associated with the farthest bottom, right position of the rail. Can be less than the configured <code>min</code> if you want values to increase from right-to-left or bottom-to-top.

Default: 100

min

Number

The value associated with the farthest top, left position of the rail. Can be greater than the configured <code>max</code> if you want values to increase from right-to-left or bottom-to-top.

Default: 0

minorStep

Number

amount to increment/decrement the Slider value when the arrow up/down/left/right keys are pressed

Default: 1

value

Number

The value associated with the thumb's current position on the rail. Defaults to the value inferred from the thumb's current position. Specifying value in the constructor will move the thumb to the position that corresponds to the supplied value.

Default: (inferred from current thumb position)