Blame view

天文台pc/tianwentai-ui/node_modules/framer-motion/dist/es/gestures/press.mjs 1.26 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
  import { Feature, press, frame } from 'motion-dom';
  import { extractEventInfo } from '../events/event-info.mjs';
  
  function handlePressEvent(node, event, lifecycle) {
      const { props } = node;
      if (node.current instanceof HTMLButtonElement && node.current.disabled) {
          return;
      }
      if (node.animationState && props.whileTap) {
          node.animationState.setActive("whileTap", lifecycle === "Start");
      }
      const eventName = ("onTap" + (lifecycle === "End" ? "" : lifecycle));
      const callback = props[eventName];
      if (callback) {
          frame.postRender(() => callback(event, extractEventInfo(event)));
      }
  }
  class PressGesture extends Feature {
      mount() {
          const { current } = this.node;
          if (!current)
              return;
          const { globalTapTarget, propagate } = this.node.props;
          this.unmount = press(current, (_element, startEvent) => {
              handlePressEvent(this.node, startEvent, "Start");
              return (endEvent, { success }) => handlePressEvent(this.node, endEvent, success ? "End" : "Cancel");
          }, {
              useGlobalTarget: globalTapTarget,
              stopPropagation: propagate?.tap === false,
          });
      }
      unmount() { }
  }
  
  export { PressGesture };
  //# sourceMappingURL=press.mjs.map