Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    A controller class for managing drag and drop workflows within an Application instance. The controller manages the following actions: dragstart, dragover, drop.

    const dragDrop = new DragDrop({
    dragSelector: ".item",
    dropSelector: ".items",
    permissions: { dragstart: this._canDragStart.bind(this), drop: this._canDragDrop.bind(this) },
    callbacks: { dragstart: this._onDragStart.bind(this), drop: this._onDragDrop.bind(this) }
    });
    dragDrop.bind(html);
    Index

    Constructors

    Properties

    callbacks: Record<
        | "dragstart"
        | "drop"
        | "dragover"
        | "dragenter"
        | "dragleave"
        | "dragend",
        (event: DragEvent) => void,
    >

    A set of callback functions for each action of the drag & drop workflow.

    dragSelector: string | null

    The HTML selector which identifies draggable elements.

    dropSelector: string | null

    The HTML selector which identifies drop targets.

    permissions: Record<"dragstart" | "drop", (selector: string) => boolean>

    A set of functions to control authorization to begin drag workflows, and drop content.

    Accessors

    • get implementation(): typeof DragDrop

      Retrieve the configured DragDrop implementation.

      Returns typeof DragDrop

    Methods

    • Bind the DragDrop controller to an HTML application

      Parameters

      • html: HTMLElement

        The HTML element to which the handler is bound

      Returns DragDrop

    • Execute a callback function associated with a certain action in the workflow

      Parameters

      • event: DragEvent

        The drag event being handled

      • action: string

        The action being attempted

      Returns any

    • Test whether the current user has permission to perform a step of the workflow

      Parameters

      • action: string

        The action being attempted

      • selector: string

        The selector being targeted

      Returns boolean

      Can the action be performed?

    • Protected

      Handle a drag workflow ending for any reason.

      Parameters

      • event: DragEvent

        The drag event.

      Returns void

    • Protected

      Handle entering a drop target while dragging.

      Parameters

      • event: DragEvent

        The drag event.

      Returns void

    • Protected

      Handle leaving a drop target while dragging.

      Parameters

      • event: DragEvent

        The drag event.

      Returns void

    • Protected

      Handle a dragged element over a droppable target

      Parameters

      • event: DragEvent

        The drag event being handled

      Returns boolean

    • Protected

      Handle the start of a drag workflow

      Parameters

      • event: DragEvent

        The drag event being handled

      Returns void

    • Protected

      Handle a dragged element dropped on a droppable target

      Parameters

      • event: DragEvent

        The drag event being handled

      Returns any

    • A helper to create an image preview element for use during HTML element dragging.

      Parameters

      • img: HTMLImageElement
      • width: number
      • height: number

      Returns HTMLDivElement