UNPKG

motion-v

Version:

<p align="center"> <img width="100" height="100" alt="Motion logo" src="https://user-images.githubusercontent.com/7850794/164965523-3eced4c4-6020-467e-acde-f11b7900ad62.png" /> </p> <h1 align="center">Motion for Vue</h1>

44 lines (43 loc) 970 B
class DragControls { constructor() { this.componentControls = /* @__PURE__ */ new Set(); } /** * Subscribe a component's internal `VisualElementDragControls` to the user-facing API. * * @internal */ subscribe(controls) { this.componentControls.add(controls); return () => this.componentControls.delete(controls); } /** * Start a drag gesture on every `motion` component that has this set of drag controls * passed into it via the `dragControls` prop. * * ```jsx * dragControls.start(e, { * snapToCursor: true * }) * ``` * * @param event - PointerEvent * @param options - Options * * @public */ start(event, options) { this.componentControls.forEach((controls) => { controls.start( event, options ); }); } } const createDragControls = () => new DragControls(); const useDragControls = createDragControls; export { DragControls, useDragControls };