Range

Range

new Range(optionsopt)

Source:
Properties:
Name Type Attributes Default Description
options.scale String | function <optional>
"linear"

Type of the value. linear, decibel, log2, frequency or a function (value, options, coef) {}. If a function instead of a constant is handed over, it receives the actual options object as the second argument and is supposed to return a coefficient between 0 and 1. If the third argument "coef" is true, it is supposed to return a value depending on a coefficient handed over as the first argument.

options.reverse Boolean <optional>
false

true if the range is reversed.

options.basis Number <optional>
0

Dimensions of the range, set to width/height in pixels, if you need it for drawing purposes, to 100 if you need percentual values or to 1 if you just need a linear coefficient for a e.g. logarithmic scale.

options.min Number <optional>
0

The minimum value possible.

options.max Number <optional>
0

The maximum value possible.

options.step Number <optional>
1

Step size, needed for e.g. user interaction

options.shift_up Number <optional>
4

Multiplier for e.g. SHIFT pressed while stepping

options.shift_down Number <optional>
0.25

Multiplier for e.g. SHIFT + CONTROL pressed while stepping

options.snap Number | Array <optional>
0

Snap the value to a virtual grid with this distance. Numbers define the step size between snaps, an array contains a list of values to snap to. Using snap option with float values causes the range to reduce its minimum and maximum values depending on the amount of decimal digits because of the implementation of math in JavaScript. Using a step size of e.g. 1.125 reduces the maximum usable value from 9,007,199,254,740,992 to 9,007,199,254,740.992 (note the decimal point).

Range is used for calculating linear scales from different values. They are useful for building coordinate systems, calculating pixel positions for different scale types, and the like. Range is used e.g. in Scale, Meter and Graph, to draw elements on a certain position according to a value on an arbitrary scale.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{ }

An object containing initial options.

Extends

Methods

addEventListener(event, func)

Source:
Inherited From:

Register an event handler.

Parameters:
Name Type Description
event string

The event descriptor.

func function

The function to call when the event happens.

delegateEvents(element) → {HTMLElement}

Source:
Inherited From:

Delegates all occuring DOM events of a specific DOM node to the widget. This way the widget fires e.g. a click event if someone clicks on the given DOM node.

Parameters:
Name Type Description
element HTMLElement

The element all native events of the widget should be bound to.

Fires:
Returns:

The element

Type
HTMLElement

destroy()

Source:
Inherited From:

Destroys all event handlers and the options object.

dispatchEvent(event, …args)

Source:
Inherited From:

Fires an event.

Parameters:
Name Type Attributes Description
event string

The event descriptor.

args * <repeatable>

Event arguments.

get(key)

Source:
Inherited From:

Get the value of an option.

Parameters:
Name Type Description
key string

The option name.

getDefault()

Source:
Inherited From:

Returns the default value of a given option. If the option does not exist, an exception is thrown.

getOptionType()

Source:
Inherited From:

Returns the type of an option. If the given option does not exist, 'undefined' is returned.

hasEventListeners(event) → {boolean}

Source:
Inherited From:

Test if the event descriptor has some handler functions in the queue.

Parameters:
Name Type Description
event string

The event desriptor.

Returns:

True if the event has some handler functions in the queue, false if not.

Type
boolean

off(event, fun)

Source:
Inherited From:

Removes the given function from the event queue. If it is a native DOM event, it removes the DOM event listener as well.

Parameters:
Name Type Description
event string

The event descriptor.

fun function

The function to remove.

reset(key)

Source:
Inherited From:

Resets an option to its default value.

Parameters:
Name Type Description
key string

The option name.

set(key, value)

Source:
Inherited From:

Sets an option. Fires both the events set with arguments key and value; and the event 'set_'+key with arguments value and key.

Parameters:
Name Type Description
key string

The name of the option.

value mixed

The value of the option.

Fires:

update(key, value)

Source:
Inherited From:

Conditionally sets an option unless it already has the requested value.

Parameters:
Name Type Description
key string

The name of the option.

value mixed

The value of the option.

Fires:

userset(key, value)

Source:
Inherited From:

Sets an option by user interaction. Emits the userset event. The userset event can be cancelled (if an event handler returns false), in which case the option is not set. Returns true if the option was set, false otherwise. If the option was set, it will emit a useraction event.

Parameters:
Name Type Description
key string

The name of the option.

value mixed

The value of the option.

Fires:
  • Base#event:userset
  • Base#event:useraction

Events

delegated

Source:
Inherited From:

Is fired when an element is delegated.

Parameters:
Name Type Description
element HTMLElement | Array

The element which receives all native DOM events.

old_element HTMLElement | Array

The element which previously received all native DOM events.

initialized

Source:
Inherited From:

Is fired when an instance is initialized.

set

Source:
Inherited From:

Is fired when an option is set.

Parameters:
Name Type Description
name string

The name of the option.

value mixed

The value of the option.

set_[option]

Source:
Inherited From:

Is fired when an option is set.

Parameters:
Name Type Description
value mixed

The value of the option.