TK.DragValue

new DragValue(options)

TK.DragValue enables dragging an element and setting a value according to the dragged distance. TK.DragValue is used in #Knob or #TK.ValueButton.

Parameters:
Name Type Description
options Object
Properties:
Name Type Attributes Default Description
options.range function

A function returning a TK.Range object for calculating the value.

options.node Element

The DOM node used for dragging. All DOM events are registered with this Element.

options.events Element <optional>
options.node

A DOM element firing the drag events.

options.classes Element <optional>
options.node

While dragging, the class toolkit-dragging will be added to this Element.

options.get function

Callback function returning the value to drag.

options.set function

Callback function for setting the value.

options.direction string <optional>
"polar"

Direction for changing the value. Can be "polar", "vertical" or "horizontal".

options.active boolean <optional>
true

If false, dragging is deactivated.

options.cursor boolean <optional>
false

If true, a global cursor is set while dragging.

options.blind_angle number <optional>
20

If options.direction is "polar", this is the angle of separation between positive and negative value changes

options.rotation number <optional>
45

Defines the angle of the center of the positive value changes. 0 means straight upward. For instance, a value of 45 leads to increasing value when moving towards top and right.

Mixes In:
Source:

Extends

Methods inherited from TK.Base

add_event(event, func, prevent, stop)

Register an event handler.

add_events(events, func)

Add multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

delegate_events(element) → {HTMLElement}

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.

destroy()

Destroys all event handlers and the options object.

fire_event(event, …args)

Fires an event.

fire_events(events)

Fires several events.

get(key)

Get the value of an option.

has_event_listeners(event) → {boolean}

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

remove_event(event, func)

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

remove_events(events, func)

Remove multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

set(key, value)

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

set_options(optionsopt)

Merges a new options object into the existing one including deep copies of objects. If an option key begins with the string "on" it is considered as event handler. In this case the value should be the handler function for the event with the corresponding name without the first "on" characters.

Events

startdrag

Is fired while a user is dragging.

Parameters:
Name Type Description
event DOMEvent

The native DOM event.

Source:

startdrag

Is fired when a user starts dragging.

Parameters:
Name Type Description
event DOMEvent

The native DOM event.

Source:

stopdrag

Is fired when a user stops dragging.

Parameters:
Name Type Description
event DOMEvent

The native DOM event.

Source:

Events inherited from TK.Base

delegated

Is fired when an element is delegated.

initialized

Is fired when an instance is initialized.

set

Is fired when an option is set.

set_[option]

Is fired when an option is set.