import { Feature } from "../../feature.mjs"; import { VisualElementDragControls } from "./VisualElementDragControls.mjs"; import { noop } from "motion-utils"; //#region src/features/gestures/drag/index.ts var DragGesture = class extends Feature { static { this.key = "drag"; } constructor(state) { super(state); this.removeGroupControls = noop; this.removeListeners = noop; this.controls = new VisualElementDragControls(state); } mount() { const { dragControls } = this.state.options; if (dragControls) this.removeGroupControls = dragControls.subscribe(this.controls); this.prevDragControls = dragControls; this.removeListeners = this.controls.addListeners() || noop; } update() { const { dragControls } = this.state.options; if (dragControls !== this.prevDragControls) { this.removeGroupControls(); this.removeGroupControls = dragControls ? dragControls.subscribe(this.controls) : noop; this.prevDragControls = dragControls; } } unmount() { this.removeGroupControls(); this.removeListeners(); if (!this.controls.isDragging) this.controls.endPanSession(); } }; //#endregion export { DragGesture };