Knob

Knob

new Knob(optionsopt)

Source:
Properties:
Name Type Attributes Default Description
options.reset Number <optional>

Reset to this value on double click.

options.bind_dblclick boolean <optional>
true

If true, bind the dblclick event to reset the value to the reset option.

options.hand Object <optional>
{width: 1, length: 12, margin: 24}
options.margin Number <optional>
13
options.thickness Number <optional>
6
options.step Number <optional>
1
options.shift_up Number <optional>
4
options.shift_down Number <optional>
0.25
options.dots_defaults Object <optional>
{length: 6, margin: 13, width: 2}
options.markers_defaults Object <optional>
{thickness: 6, margin: 13}
options.labels_defaults Object <optional>
{margin: 10, align: "outer", format: function(val){return val;}}
options.basis Number <optional>
300

Distance to drag between min and max.

options.preset String <optional>
"medium"

The preset to use. Presets are a functionality of Widget.

[options.presets={ tiny: {margin:0, thickness:4, hand:{width: 1, length: 6, margin: 8}, dots_defaults:{length:4, margin:0, width:1}, markers_defaults: {thickness: 2, margin: 0}, show_labels:false}, small: {margin:0, thickness:5, hand:{width: 1, length: 8, margin: 10}, dots_defaults: {length:5, margin:0,width:1}, markers_defaults: {thickness: 2, margin: 0}, show_labels:false}, medium: {}, large: {hand:{width:1.5, length:12, margin:26}}, huge: {hand:{width:2, length:12, margin:28}}, }] Object

A set of available presets. Presets are a functionality of Widget.

Knob is a Circular inside of an SVG which can be modified both by dragging and scrolling utilizing DragValue and ScrollValue. It inherits all options of Circular and DragValue. The options listed below consist of options from the contained widgets, only showing the default values.

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

An object containing initial options.

Extends

Members

circular :Circular

Source:

The Circular module.

Type:

drag :DragValue

Source:

Instance of DragValue used for the interaction.

Type:

drag :DragValue

Source:

Instance of DragValue used for interaction.

Type:

element :HTMLDivElement

Source:

The main DIV container. Has class .aux-knob.

Type:
  • HTMLDivElement

scroll :ScrollValue

Source:

Instance of ScrollValue used for the interaction.

Type:

scroll :ScrollValue

Source:

Instance of ScrollValue used for interaction.

Type:

svg :SVGImage

Source:

The main SVG image.

Type:
  • SVGImage

Methods

addChild(child)

Source:
Inherited From:
See:

Registers a widget as a child widget. This method is used to build up the widget tree. It does not modify the DOM tree.

Parameters:
Name Type Description
child Widget

The child to add.

Fires:
  • Widget#event:child_added

addChildren(a)

Source:
Inherited From:

Registers an array of widgets as children.

Parameters:
Name Type Description
a Array.<Widget>

An array of Widgets.

addLabel()

Source:

This is an alias for Circular#addLabel of the internal circular instance.

allChildren()

Source:
Inherited From:

Returns an array of all children.

appendChild(child)

Source:
Inherited From:

Appends child.element to the widget element and registers child as a child widget.

Parameters:
Name Type Description
child Widget

The child widget to append.

appendChildren(children)

Source:
Inherited From:

Calls Widget#appendChild for an array of widgets.

Parameters:
Name Type Description
children Array.<Widget>

The child widgets to append.

destroy()

Source:
Overrides:

Dispose of this Widget.

destroyAndRemove()

Source:
Inherited From:

Dispose of this Widget and remove it from the DOM.

disableTansitions()

Source:
Inherited From:

Disable CSS transitions.

enableDraw()

Source:
Overrides:

Schedules this widget for drawing.

Fires:

enableDrawChildren()

Source:
Inherited From:

Enables rendering for all children of this widget.

enableTransitions()

Source:
Inherited From:

Enable CSS transitions.

forceHide()

Source:
Inherited From:

Hide the widget immediately by applying the class aux-hide. Does not call disableDraw().

forceShow()

Source:
Inherited From:

Show the widget immediately by applying the class aux-show. Does not call enableDraw().

getStyle()

Source:
Inherited From:

Returns the computed style of this widget's DOM element.

hidden()

Source:
Inherited From:

Returns the current hidden status.

hide()

Source:
Inherited From:

Hide the widget. This will result in the class aux-hide being applied to this widget in the next rendering step.

invalidate(key)

Source:
Inherited From:

Invalidates an option and triggers a redraw() call.

Parameters:
Name Type Description
key string

invalidateAll()

Source:
Inherited From:

Invalidates all dependencies which will trigger all renderers to rerun.

observeResize(cb)

Source:
Inherited From:

Calls a callback whenever the widget resizes. This method will trigger one resize.

Parameters:
Name Type Description
cb function

removeChild(child)

Source:
Inherited From:

Removes a child widget. Note that this method only modifies the widget tree and does not change the DOM.

Parameters:
Name Type Description
child Widget

The child to remove.

Fires:
  • Widget#event:child_removed

removeChildren(a)

Source:
Inherited From:

Removes an array of children.

Parameters:
Name Type Description
a Array.<Widget>

An array of Widgets.

removeLabel()

Source:

This is an alias for Circular#removeLabel of the internal circular instance.

set(key, value)

Source:
Overrides:

Sets an option.

Parameters:
Name Type Description
key string

The option name.

value

The option value.

setStyle()

Source:
Inherited From:

Sets a CSS style property in this widget's DOM element.

show()

Source:
Inherited From:

Make the widget visible. This will apply the class aux-show during the next rendering step.

toggleHidden()

Source:
Inherited From:

Toggle the hidden status. This is equivalent to calling hide() or show(), depending on the current hidden status of this widget.

transitionsDisabled()

Source:
Inherited From:

Returns true if transitions are currently disabled on this widget.

visibleChildren()

Source:
Inherited From:

Returns an array of all visible children.

Events

destroy

Source:
Inherited From:

Is fired when a widget is destroyed.

doubleclick

Source:
Overrides:

Is fired when the knob receives a double click in order to reset to initial value.

Parameters:
Name Type Description
value number

The value of the widget.

GenericDOMEvents

Source:
Inherited From:

Generic DOM events. Please refer to W3Schools for further details.

hide

Source:
Inherited From:

The hide event is emitted when a widget is hidden and is not rendered anymore. This happens both with browser visibility changes and also internally when using layout widgets such as Pager.

initialized

Source:
Inherited From:

Is fired when a widget is initialized.

resize

Source:
Inherited From:

The resize event is emitted whenever a widget is being resized. This event can be used to e.g. measure its new size. Note that some widgets do internal adjustments after the resize event. If that is relevant, the Widget#resized event can be used instead.

resized

Source:
Inherited From:

The resized event is emitted after each rendering frame, which was triggered by a resize event.

set

Source:
Inherited From:

The set event is emitted when an option was set using the Widget#set method. The arguments are the option name and its new value.

Note that this happens both for user interaction and programmatical option changes.

show

Source:
Inherited From:

The show event is emitted when a widget is shown and is being rendered. This is the counterpart to Widget#hide.

useraction

Source:

The useraction event is emitted when a widget gets modified by user interaction. The event is emitted for the option value.

Parameters:
Name Type Description
name string

The name of the option which was changed due to the users action

value mixed

The new value of the option

visibility

Source:
Inherited From:

Is fired when the visibility state changes. The first argument is the visibility state, which is either true or false.