@witchcraft/layout
    Preparing search index...

    Interface IDragAction

    A drag action describes when and how to handle a drag event.

    For example, there are the default split/close actions that can be triggered in certain situations. This could be when holding down a modifier or key, or some other condition (e.g. the user is dragging a specific edge).

    Each action should handle it's configuration and saving/caching any state it needs. See SplitAction and CloseAction for examples.

    interface IDragAction {
        name: string;
        onDragApply: (
            state: DragState,
            forceRecalculateEdges: () => void,
        ) => boolean;
        onDragChange: DragChangeHandler;
        cancel(): void;
        canHandleRequest(
            e: PointerEvent | KeyboardEvent,
            state: DragState,
            forceRecalculateEdges: () => void,
        ): boolean;
    }

    Implemented by

    Index

    Properties

    name: string

    A unique name for your action.

    onDragApply: (state: DragState, forceRecalculateEdges: () => void) => boolean

    Is called after onDragChange("end") with the same event. Might not be called if the request was cancelled.

    You should apply your action if possible and return whether it was applied.

    This is also a good place to reset your state.

    onDragChange: DragChangeHandler

    Called when the drag coordinates change (during any event). Should return true to allow the edges to be moved, or false to prevent it.

    Can be used to save some context/info to later apply safely during onDragApply.

    Methods

    • Should return true if it should handle the "request"/event (e.g. some modifier is being pressed => user is requesting x action).

      The user is not necessarily dragging at this point, though they might also change actions mid drag. So it does not necessarily mean the event is allowed.

      Here is where you should initiate your state. Don't allow the action by default unless it can always be allowed.

      Parameters

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

      Returns boolean