import type { Constraint, ConstraintCallbacks, Coord } from "./types"; import type { Graphie } from "../util/graphie"; interface State { added?: boolean; isHovering?: boolean; isMouseOver?: boolean; isDragging?: boolean; mouseTarget?: { toFront(): void; toBack(): void; remove(): void; getMouseTarget(): Element; } | null; cursor?: null; id: string; add?: (() => void)[]; modify?: ((state: State, prevState?: State) => void)[]; draw?: ((state: State, prevState?: State) => void)[]; remove?: (() => void)[]; onMoveStart?: ((position: Coord, positionAgain: Coord) => void)[]; onMove?: ((end: Coord, start: Coord) => void)[]; onMoveEnd?: ((end: Coord, start: Coord) => void)[]; onClick?: ((position: Coord, start: Coord) => void)[]; constraints?: Constraint[]; } export declare class Movable> { graphie: Graphie; state: State; prevState: State | undefined; _listenerMap: Record; constructor(graphie: Graphie, options: Options); modify(options: Options): void; _createDefaultState(): { cursor: null; id: string; add: never[]; modify: never[]; draw: never[]; remove: never[]; onMoveStart: never[]; onMove: never[]; onMoveEnd: never[]; onClick: never[]; }; update(options: Options): void; cloneState(): State; /** * Fire an onSomething type event to all functions in listeners */ _fireEvent any>(listeners: F[] | undefined, ...args: Parameters): void; /** * Call all draw functions, and update our prevState for the next * draw function */ draw(): void; /** * Simulates a mouse grab event on the movable object. */ grab(coord: Coord): void; _applyConstraints(current: Coord, previous: Coord, extraOptions?: ConstraintCallbacks): false | Coord; toBack(): void; toFront(): void; /** * Add a listener to any event: startMove, constraints, onMove, onMoveEnd, * etc. If a listener is already bound to the given eventName and id, then * it is overwritten by func. * * eventName: the string name of the event to listen to. one of: * "onMoveStart", "onMove", "onMoveEnd", "draw", "remove" * * id: a string id that can be used to remove this event at a later time * note: adding multiple listeners with the same id is undefined behavior * * func: the function to call when the event happens, which is called * with the event's standard parameters [usually (coord, prevCoord) or * (state, prevState)] */ listen(eventName: string, id: string, func: () => unknown): void; /** * Remove a previously added listener, by the id specified in the * corresponding listen() call * * If the given id has not been registered already, this is a no-op */ unlisten(eventName: string, id: string): void; remove(): void; cursor(): null | undefined; added(): boolean | undefined; isHovering(): boolean | undefined; isMouseOver(): boolean | undefined; isDragging(): boolean | undefined; mouseTarget(): { toFront(): void; toBack(): void; remove(): void; getMouseTarget(): Element; } | null | undefined; } export {};