DragCapture

DragCapture

new DragCapture(widget, optionsopt)

Source:
Properties:
Name Type Attributes Default Description
options.node HTMLElement <optional>

The DOM element receiving the drag events. If not set the widgets element is used.

options.focus HTMLElement | Boolean <optional>
false

Focus this element on scroll. Set to false if no focus should be set.

DragCapture is a low-level class for tracking drag interaction using both touch and mouse events. It can be used for implementing drag'n'drop functionality as well as value dragging e.g. Fader or Knob. DragValue derives from DragCapture.

Each drag interaction started by the user begins with the startcapture event. If an event handler returns true, the dragging is started. Otherwise mouse or touch events which belong to the same drag interaction are ignored.

While the drag interaction is running, the movecapture is fired for each underlying move event. Once the drag interaction completes, the stopcapture event is fired.

While the drag interaction is running, the state() method returns a CaptureState object. This object has methods for calculating current position, distance from the start position etc.

Parameters:
Name Type Attributes Default Description
widget Object

The parent widget making use of DragValue.

options Object <optional>
{ }

An object containing initial options.

Extends

  • Module

Events

movecapture

Source:

A movement was captured.

Parameters:
Name Type Description
event DOMEvent

The event object of the current move event.

startcapture

Source:

Capturing started.

Parameters:
Name Type Description
state object

An internal state object.

start DOMEvent

The event object of the initial event.

stopcapture

Source:

Capturing stopped.

Parameters:
Name Type Description
state object

An internal state object.

event DOMEvent

The event object of the current event.