@witchcraft/layout
    Preparing search index...

    Class DragActionHandler<TRawDragActions, TDragActions>

    Handles the lifecycle of a drag actions IDragAction and provides additional hooks.

    The first action instance that can handle the request is passed control of the event handlers until the request changes.

    Type Parameters

    Index

    Constructors

    • Type Parameters

      Parameters

      • defaultOnDragChange: DragChangeHandler

        Default onDragChange handler for when no action can handle the request.

        Should return true to allow the edges to be moved, or false to prevent it.

      • actions: TRawDragActions
      • hooks: {
            onEnd?: (context: { applied: boolean; cancelled: boolean }) => void;
            onEvent?: (
                e: undefined | PointerEvent | KeyboardEvent,
                cancel: () => void,
            ) => void;
            onRecalculate?: () => void;
            onRequestChange?: (type: undefined | keyof TDragActions) => void;
        } = {}
        • OptionalonEnd?: (context: { applied: boolean; cancelled: boolean }) => void

          Called when the drag action ends either because it was completed or cancelled.

        • OptionalonEvent?: (e: undefined | PointerEvent | KeyboardEvent, cancel: () => void) => void

          Called before searching for a matching action. Useful for re-initializing state.

          Is passed a cancel function if you want to cancel the current drag action.

        • OptionalonRecalculate?: () => void

          Called while dragging during dragChange events. You can use this to update the dragging edges.

        • OptionalonRequestChange?: (type: undefined | keyof TDragActions) => void

          Called when the action requested changes.

      Returns DragActionHandler<TRawDragActions, TDragActions>

    Properties

    actions: TDragActions
    activeAction?: keyof TDragActions
    boundCancel: () => void
    defaultOnDragChange: DragChangeHandler
    eventCanceller: undefined | (() => void) = undefined
    hooks: {
        onEnd?: (context: { applied: boolean; cancelled: boolean }) => void;
        onEvent?: (
            e: undefined | PointerEvent | KeyboardEvent,
            cancel: () => void,
        ) => void;
        onRecalculate?: () => void;
        onRequestChange?: (type: undefined | keyof TDragActions) => void;
    }

    Type Declaration

    • OptionalonEnd?: (context: { applied: boolean; cancelled: boolean }) => void

      Called when the drag action ends either because it was completed or cancelled.

    • OptionalonEvent?: (e: undefined | PointerEvent | KeyboardEvent, cancel: () => void) => void

      Called before searching for a matching action. Useful for re-initializing state.

      Is passed a cancel function if you want to cancel the current drag action.

    • OptionalonRecalculate?: () => void

      Called while dragging during dragChange events. You can use this to update the dragging edges.

    • OptionalonRequestChange?: (type: undefined | keyof TDragActions) => void

      Called when the action requested changes.

    Methods

    • Parameters

      • e: PointerEvent | KeyboardEvent
      • state: DragState
      • forceRecalculateEdges: () => void

      Returns undefined

    • Type Parameters

      • T extends "start" | "move" | "end"

      Parameters

      • type: T
      • e: T extends "end" ? undefined | PointerEvent : PointerEvent
      • state: DragState
      • forceRecalculateEdges: () => void
      • Optionalcancel: () => void

      Returns undefined | boolean