Draggable
Mixin
internal
Mix this into another class to enable drag/drop support.
To use a draggable, it must be associated with an element that contains draggable content:
let draggable = new MyDraggable({
dragRootElement : someElement
});
Once the dragRootElement is assigned, any element inside that root is a candidate for dragging. To limit the allowed element, set the dragSelector config.
let draggable = new MyDraggable({
dragRootElement : someElement,
dragSelector : '.drag-this'
});
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
The listeners to add to the
documentduring a drag. -
A CSS class to add to items identified by the dragItemSelector when the mouse enters.
-
A CSS selector to use to ascend from the drag element to find the element that will gain the draggingItemCls CSS class. If not supplied, the drag element will gain this CSS class.
-
Configure as
'x'to lock dragging to theXaxis (the drag will only move horizontally) or'y'to lock dragging to theYaxis (the drag will only move vertically). -
The minimum distance a drag must move to be considered a drop and not aborted.
-
The drag proxy is a helper object that can be used to display feedback during a drag.
-
The outer element where dragging will operate (attach events to it and use as root limit when looking for ancestors).
-
Set to
trueto allow a drag to drop on to the same element from which the drag started. -
A CSS selector used to determine which element(s) can be dragged.
-
The number of milliseconds after a pointerup to ignore click events on the document. This is used to avoid the "up" event itself generating a
clickon the target. -
The amount of pixels to move pointer/mouse before it counts as a drag operation.
-
The number of milliseconds that must elapse after a
touchstartevent before it is considered a drag. If movement occurs before this time, the drag is aborted. This is to allow touch swipes and scroll gestures. -
A CSS selector to use to ascend from the dragRootElement to find the element that will gain the draggingCls and draggingStartedCls CSS classes.
-
The CSS selector to use to identify the closest valid target from the event target.
-
A CSS selector used to identify child element(s) that should not trigger drag.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Draggable class, or subclass thereof.
-
Return the
Eventsinstance from which drag events are fired. -
The CSS class that is added to the dragRootElement, i.e.,
'b-draggable'. -
The current
DragContext. This is created immediately on pointerdown but does not become active until some movement occurs. This threshold is configurable. -
The CSS class to add to the
bodyelement as soon as the dragThreshold is reached and an actual drag is in progress. -
The CSS class to add to the dragRootElement (or draggingClsSelector from there) as soon as the pointerdown event occurs.
-
The CSS class to add to the element being dragged as soon as the pointerdown event occurs.
-
The CSS class to add to the dragRootElement (or draggingClsSelector from there) as soon as the dragThreshold is reached and an actual drag is in progress.
-
The dragSelector item the mouse is currently over.
-
Identifies an object as an instance of Draggable class, or subclass thereof.