Blame view

天文台pc/tianwentai-ui/node_modules/motion-dom/dist/es/render/dom/DOMVisualElement.mjs 1.43 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
  import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
  import { DOMKeyframesResolver } from '../../animation/keyframes/DOMKeyframesResolver.mjs';
  import { VisualElement } from '../VisualElement.mjs';
  
  class DOMVisualElement extends VisualElement {
      constructor() {
          super(...arguments);
          this.KeyframeResolver = DOMKeyframesResolver;
      }
      sortInstanceNodePosition(a, b) {
          /**
           * compareDocumentPosition returns a bitmask, by using the bitwise &
           * we're returning true if 2 in that bitmask is set to true. 2 is set
           * to true if b preceeds a.
           */
          return a.compareDocumentPosition(b) & 2 ? 1 : -1;
      }
      getBaseTargetFromProps(props, key) {
          const style = props.style;
          return style ? style[key] : undefined;
      }
      removeValueFromRenderState(key, { vars, style }) {
          delete vars[key];
          delete style[key];
      }
      handleChildMotionValue() {
          if (this.childSubscription) {
              this.childSubscription();
              delete this.childSubscription;
          }
          const { children } = this.props;
          if (isMotionValue(children)) {
              this.childSubscription = children.on("change", (latest) => {
                  if (this.current) {
                      this.current.textContent = `${latest}`;
                  }
              });
          }
      }
  }
  
  export { DOMVisualElement };
  //# sourceMappingURL=DOMVisualElement.mjs.map