Module: drag

Drag module

Source:

Methods

(static) makeInteractableDraggable(interactable, checkDrop, isDraggable)

This function allows an element to be dragged across the screen with the mouse.
During the drag, the element's style changes for visual feedback (e.g., scaling
and reduced opacity). The checkDrop callback verifies if the drop is valid,
resetting the element's position if it's not.

Parameters:
Name Type Description
interactable HTMLElement

The element to make draggable.

checkDrop function

A callback function to check
if the interactable is dropped in a valid drop zone. Should return true if valid.

isDraggable function

A callback function to determine
if the element can be dragged. Should return true if draggable.

Source:
Example
// Make a patch draggablemakeInteractableDraggable(patchElement, checkDropCallback, () => isDraggable);

(inner) resetInteractable(interactable)

Resets the position and styling of a draggable element.

Parameters:
Name Type Description
interactable HTMLElement

The draggable element to reset.

Source: