{"version":3,"file":"index.mjs","sources":["../../../../src/gestures/drag/index.ts"],"sourcesContent":["import { Feature, type VisualElement } from \"motion-dom\"\nimport { noop } from \"motion-utils\"\nimport { VisualElementDragControls } from \"./VisualElementDragControls\"\n\nexport class DragGesture extends Feature<HTMLElement> {\n    controls: VisualElementDragControls\n\n    removeGroupControls: Function = noop\n    removeListeners: Function = noop\n\n    constructor(node: VisualElement<HTMLElement>) {\n        super(node)\n        this.controls = new VisualElementDragControls(node)\n    }\n\n    mount() {\n        // If we've been provided a DragControls for manual control over the drag gesture,\n        // subscribe this component to it on mount.\n        const { dragControls } = this.node.getProps()\n\n        if (dragControls) {\n            this.removeGroupControls = dragControls.subscribe(this.controls)\n        }\n\n        this.removeListeners = this.controls.addListeners() || noop\n    }\n\n    update() {\n        const { dragControls } = this.node.getProps()\n        const { dragControls: prevDragControls } = this.node.prevProps || {}\n\n        if (dragControls !== prevDragControls) {\n            this.removeGroupControls()\n            if (dragControls) {\n                this.removeGroupControls = dragControls.subscribe(this.controls)\n            }\n        }\n    }\n\n    unmount() {\n        this.removeGroupControls()\n        this.removeListeners()\n        /**\n         * In React 19, during list reorder reconciliation, components may\n         * briefly unmount and remount while the drag is still active. If we're\n         * actively dragging, we should NOT end the pan session - it will\n         * continue tracking pointer events via its window-level listeners.\n         *\n         * The pan session will be properly cleaned up when:\n         * 1. The drag ends naturally (pointerup/pointercancel)\n         * 2. The component is truly removed from the DOM\n         */\n        if (!this.controls.isDragging) {\n            this.controls.endPanSession()\n        }\n    }\n}\n"],"names":[],"mappings":";;;;AAIM,MAAO,WAAY,SAAQ,OAAoB,CAAA;AAMjD,IAAA,WAAA,CAAY,IAAgC,EAAA;QACxC,KAAK,CAAC,IAAI,CAAC;QAJf,IAAA,CAAA,mBAAmB,GAAa,IAAI;QACpC,IAAA,CAAA,eAAe,GAAa,IAAI;QAI5B,IAAI,CAAC,QAAQ,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC;IACvD;IAEA,KAAK,GAAA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