import MoveableManager from "./MoveableManager"; import { prefix, getControlTransform } from "./utils"; import { ResizableProps, ScalableProps, WarpableProps, Renderer } from "./types"; import { DIRECTION_INDEXES } from "./consts"; import { IObject } from "@daybrush/utils"; export function renderControls( moveable: MoveableManager>, defaultDirections: string[], React: Renderer, ): any[] { const { pos1, pos2, pos3, pos4 } = moveable.state; const { renderDirections: directions = defaultDirections, } = moveable.props; const poses = [pos1, pos2, pos3, pos4]; const directionMap: IObject = {}; directions.forEach(direction => { directionMap[direction] = true; }); return directions.map(direction => { const indexes = DIRECTION_INDEXES[direction]; if (!indexes || !directionMap[direction]) { return null; } return (
poses[index]))}>
); }); } export function renderAllDirections( moveable: MoveableManager>, React: Renderer, ) { return renderControls(moveable, ["nw", "ne", "sw", "se", "n", "w", "s", "e"], React); } export function renderDiagonalDirections( moveable: MoveableManager>, React: Renderer, ): any[] { return renderControls(moveable, ["nw", "ne", "sw", "se"], React); }