DragSelect

DragSelect

DragSelect

Constructor

new DragSelect(settings)

Source:
Parameters:
Name Type Description
settings Settings

Members

break

Utility to override DragSelect internal functionality: Break will skip the selection or dragging functionality (until after the callback) but let everything continue to run. Useful utility to write your own functionality/move/dragNdrop based on DragSelect pointer positions.
Source:

continue :boolean

used to skip all current Selection and dragNdrop functionality
Source:
Type:
  • boolean

getCurrentCursorPosition

The last seen position of the cursor/selector @return {Vect2}
Source:

getCurrentCursorPositionArea

The last seen position of the cursor/selector @return {Vect2}
Source:

getInitialCursorPosition

The starting/initial position of the cursor/selector @return {Vect2}
Source:

getInitialCursorPositionArea

The starting/initial position of the cursor/selector @return {Vect2}
Source:

getPreviousCursorPosition

The previous position of the cursor/selector @return {Vect2}
Source:

getPreviousCursorPositionArea

The previous position of the cursor/selector @return {Vect2}
Source:

getSelectables

Gets all nodes that can potentially be selected
Source:

getSelection

Returns the current selected nodes
Source:

isDragging

Whether the user is currently drag n dropping elements (instead of selection)
Source:

isMultiSelect

Whether the multi-selection key was pressed
Source:

start

Initializes the functionality. Automatically triggered when created. Also, reset the functionality after a teardown
Source:

Methods

addSelectables(elements, addToSelectionopt) → {DSInputElements}

Add elements that can be selected. No node is added twice
Source:
Parameters:
Name Type Attributes Default Description
elements DSInputElements dom element(s)
addToSelection boolean <optional>
false if elements should also be added to current selection
Returns:
Type:
DSInputElements
the added element(s)

addSelection(elements, triggerCallbackopt, dontAddToSelectablesopt) → {DSElements}

Adds several elements to the selection list also adds the specific classes and take into account all calculations. Does not clear the selection, in contrary to .setSelection. Can add multiple elements at once
Source:
Parameters:
Name Type Attributes Default Description
elements DSInputElements one or multiple elements
triggerCallback boolean <optional>
false if callback should be called
dontAddToSelectables boolean <optional>
false if element should not be added to the list of selectable elements
Returns:
Type:
DSElements
all selected elements

clearSelection(triggerCallbackopt) → {DSElements}

Unselect / Deselect all current selected Nodes
Source:
Parameters:
Name Type Attributes Default Description
triggerCallback boolean <optional>
false if callback should be called
Returns:
Type:
DSElements
this.selected, should be empty

getCursorPositionDifference(usePreviousCursorDifferenceopt, useAreaPositionsopt) → {Vect2}

Utility method that returns the cursor position difference between start and now
Deprecated:
  • Yes
Source:
Parameters:
Name Type Attributes Default Description
usePreviousCursorDifference boolean <optional>
false if true, it will output the cursor position difference between the previous selection and now
useAreaPositions boolean <optional>
false if true, it will use cursor positions relative to the area
Returns:
Type:
Vect2

publish(eventName, data)

Publishes an event to all subscribers
Source:
Parameters:
Name Type Description
eventName DSCallbackNames
data CallbackObject passed to the subscription method

removeSelectables(elements, removeFromSelectionopt) → {DSInputElements}

Remove elements from the elements that can be selected.
Source:
Parameters:
Name Type Attributes Default Description
elements DSInputElements – dom element(s)
removeFromSelection boolean <optional>
false if elements should also be removed from current selection
Returns:
Type:
DSInputElements
the removed element(s)

removeSelection(elements, triggerCallbackopt, removeFromSelectablesopt) → {DSElements}

Removes specific elements from the selection Multiple elements can be given at once, in contrary to unselect
Source:
Parameters:
Name Type Attributes Default Description
elements DSInputElements one or multiple elements
triggerCallback boolean <optional>
false if callback should be called
removeFromSelectables boolean <optional>
false if element should be removed from the list of selectable elements
Returns:
Type:
DSElements
all selected elements

setSelectables(elements, removeFromSelectionopt, addToSelectionopt) → {DSInputElements}

Sets all elements that can be selected. Removes all current selectables (& their respective classes). Adds the new set to the selectables set, thus replacing the original set.
Source:
Parameters:
Name Type Attributes Default Description
elements DSInputElements – dom element(s)
removeFromSelection boolean <optional>
false if elements should also be removed from current selection
addToSelection boolean <optional>
false if elements should also be added to current selection
Returns:
Type:
DSInputElements
elements – the added element(s)

setSelection(elements, triggerCallbackopt, dontAddToSelectablesopt) → {DSElements}

Sets the current selected elements and optionally run the callback By default, adds new elements also to the list of selectables
Source:
Parameters:
Name Type Attributes Default Description
elements DSInputElements – dom elements
triggerCallback boolean <optional>
false if callback should be called
dontAddToSelectables boolean <optional>
false if element should not be added to the list of selectable elements
Returns:
Type:
DSElements

stop(removeopt, fromSelectionopt, withCallbackopt)

Complete function teardown Will teardown/stop the whole functionality
Source:
Parameters:
Name Type Attributes Default Description
remove boolean <optional>
true if elements should be removed.
fromSelection boolean <optional>
true if elements should also be added/removed to the selection.
withCallback boolean <optional>
false if elements should also be added/removed to the selection.

subscribe(eventName, callback) → {number}

Subscribe to an event
Source:
Parameters:
Name Type Description
eventName DSCallbackNames
callback DSCallback
Returns:
Type:
number
event id, can be used to unsubscribe more efficiently

toggleSelection(elements, triggerCallbackopt, alsoSelectablesopt) → {DSElements}

Toggles specific elements from the selection: If element is not in selection it will be added, if it is already selected, it will be removed. Multiple elements can be given at once.
Source:
Parameters:
Name Type Attributes Default Description
elements DSInputElements one or multiple elements
triggerCallback boolean <optional>
false if callback should be called
alsoSelectables boolean <optional>
false if element should not be added/removed to the list of selectable elements accordingly
Returns:
Type:
DSElements
all selected elements

unsubscribe(eventName, callbackopt, idopt)

Removes event subscription
Source:
Parameters:
Name Type Attributes Description
eventName DSCallbackNames
callback DSCallback <optional>
the callback method signature, has to be exactly the same as when subscribing. Consider using "id" instead.
id number <optional>
event id returned when subscribed (more performant than callback search)