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>

74 lines (73 loc) 2.09 kB
import { DragControlOptions, VisualElementDragControls } from './VisualElementDragControls'; /** * Can manually trigger a drag gesture on one or more `drag`-enabled `motion` components. * * ```jsx * const dragControls = useDragControls() * * function startDrag(event) { * dragControls.start(event, { snapToCursor: true }) * } * * return ( * <> * <div onPointerDown={startDrag} /> * <motion.div drag="x" dragControls={dragControls} /> * </> * ) * ``` * * @public */ export declare class DragControls { private componentControls; /** * Subscribe a component's internal `VisualElementDragControls` to the user-facing API. * * @internal */ subscribe(controls: VisualElementDragControls): () => void; /** * 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: PointerEvent, options?: DragControlOptions): void; } /** * Usually, dragging is initiated by pressing down on a `motion` component with a `drag` prop * and moving it. For some use-cases, for instance clicking at an arbitrary point on a video scrubber, we * might want to initiate that dragging from a different component than the draggable one. * * By creating a `dragControls` using the `useDragControls` hook, we can pass this into * the draggable component's `dragControls` prop. It exposes a `start` method * that can start dragging from pointer events on other components. * * ```jsx * const dragControls = useDragControls() * * function startDrag(event) { * dragControls.start(event, { snapToCursor: true }) * } * * return ( * <> * <div onPointerDown={startDrag} /> * <motion.div drag="x" dragControls={dragControls} /> * </> * ) * ``` * * @public */ export declare const useDragControls: () => DragControls;