Blame view

天文台pc/tianwentai-ui/node_modules/framer-motion/dist/es/gestures/drag/index.mjs 1.89 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  import { Feature } from 'motion-dom';
  import { noop } from 'motion-utils';
  import { VisualElementDragControls } from './VisualElementDragControls.mjs';
  
  class DragGesture extends Feature {
      constructor(node) {
          super(node);
          this.removeGroupControls = noop;
          this.removeListeners = noop;
          this.controls = new VisualElementDragControls(node);
      }
      mount() {
          // If we've been provided a DragControls for manual control over the drag gesture,
          // subscribe this component to it on mount.
          const { dragControls } = this.node.getProps();
          if (dragControls) {
              this.removeGroupControls = dragControls.subscribe(this.controls);
          }
          this.removeListeners = this.controls.addListeners() || noop;
      }
      update() {
          const { dragControls } = this.node.getProps();
          const { dragControls: prevDragControls } = this.node.prevProps || {};
          if (dragControls !== prevDragControls) {
              this.removeGroupControls();
              if (dragControls) {
                  this.removeGroupControls = dragControls.subscribe(this.controls);
              }
          }
      }
      unmount() {
          this.removeGroupControls();
          this.removeListeners();
          /**
           * In React 19, during list reorder reconciliation, components may
           * briefly unmount and remount while the drag is still active. If we're
           * actively dragging, we should NOT end the pan session - it will
           * continue tracking pointer events via its window-level listeners.
           *
           * The pan session will be properly cleaned up when:
           * 1. The drag ends naturally (pointerup/pointercancel)
           * 2. The component is truly removed from the DOM
           */
          if (!this.controls.isDragging) {
              this.controls.endPanSession();
          }
      }
  }
  
  export { DragGesture };
  //# sourceMappingURL=index.mjs.map