Drag

Drag

new Drag(optionsopt)

Source:
Properties:
Name Type Attributes Default Description
options.node HTMLElement | SVGElement

The element to drag.

options.handle HTMLElement | SVGElement <optional>

A DOM node to be used as a handle. If not set, options.node is used.

options.active Boolean <optional>
true

Enable or disable dragging

options.min Object | Boolean <optional>
{x: false, y: false}

Object containing the minimum positions for x and y. A value of false is interpreted as no minimum.

options.max Object | Boolean <optional>
{x: false, y: false}

Object containing the maximum positions for x and y. A value of false is interpreted as no maximum.

options.initial Number <optional>
2

Number of pixels the user has to move until dragging starts.

options.transform Boolean <optional>
false

Use CSS transformations instead of absolute positioning.

Drag enables dragging of elements on the screen positioned absolutely or by CSS transformation.

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:
Overrides:

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.

dragging

Source:

The user is dragging this item.

Parameters:
Name Type Description
event DOMEvent

The native DOM event.

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.

startdrag

Source:

The user started dragging this item.

Parameters:
Name Type Description
event DOMEvent

The native DOM event.

stopdrag

Source:

The user stopped dragging this item.

Parameters:
Name Type Description
event DOMEvent

The native DOM event.