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>

27 lines (26 loc) 885 B
import { Feature } from "../../feature.mjs"; import { VisualElementDragControls } from "./VisualElementDragControls.mjs"; import { noop } from "../../../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/noop.mjs"; import "../../../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs"; class DragGesture extends Feature { constructor(state) { super(state); this.removeGroupControls = noop; this.removeListeners = noop; this.controls = new VisualElementDragControls(state.visualElement); } mount() { const { dragControls } = this.state.options; if (dragControls) { this.removeGroupControls = dragControls.subscribe(this.controls); } this.removeListeners = this.controls.addListeners() || noop; } unmount() { this.removeGroupControls(); this.removeListeners(); } } export { DragGesture };