Blame view

天文台pc/tianwentai-ui/node_modules/motion-dom/dist/es/projection/geometry/delta-remove.mjs 2.5 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
52
53
54
55
  import { mixNumber } from '../../utils/mix/number.mjs';
  import { percent } from '../../value/types/numbers/units.mjs';
  import { scalePoint } from './delta-apply.mjs';
  
  /**
   * Remove a delta from a point. This is essentially the steps of applyPointDelta in reverse
   */
  function removePointDelta(point, translate, scale, originPoint, boxScale) {
      point -= translate;
      point = scalePoint(point, 1 / scale, originPoint);
      if (boxScale !== undefined) {
          point = scalePoint(point, 1 / boxScale, originPoint);
      }
      return point;
  }
  /**
   * Remove a delta from an axis. This is essentially the steps of applyAxisDelta in reverse
   */
  function removeAxisDelta(axis, translate = 0, scale = 1, origin = 0.5, boxScale, originAxis = axis, sourceAxis = axis) {
      if (percent.test(translate)) {
          translate = parseFloat(translate);
          const relativeProgress = mixNumber(sourceAxis.min, sourceAxis.max, translate / 100);
          translate = relativeProgress - sourceAxis.min;
      }
      if (typeof translate !== "number")
          return;
      let originPoint = mixNumber(originAxis.min, originAxis.max, origin);
      if (axis === originAxis)
          originPoint -= translate;
      axis.min = removePointDelta(axis.min, translate, scale, originPoint, boxScale);
      axis.max = removePointDelta(axis.max, translate, scale, originPoint, boxScale);
  }
  /**
   * Remove a transforms from an axis. This is essentially the steps of applyAxisTransforms in reverse
   * and acts as a bridge between motion values and removeAxisDelta
   */
  function removeAxisTransforms(axis, transforms, [key, scaleKey, originKey], origin, sourceAxis) {
      removeAxisDelta(axis, transforms[key], transforms[scaleKey], transforms[originKey], transforms.scale, origin, sourceAxis);
  }
  /**
   * The names of the motion values we want to apply as translation, scale and origin.
   */
  const xKeys = ["x", "scaleX", "originX"];
  const yKeys = ["y", "scaleY", "originY"];
  /**
   * Remove a transforms from an box. This is essentially the steps of applyAxisBox in reverse
   * and acts as a bridge between motion values and removeAxisDelta
   */
  function removeBoxTransforms(box, transforms, originBox, sourceBox) {
      removeAxisTransforms(box.x, transforms, xKeys, originBox ? originBox.x : undefined, sourceBox ? sourceBox.x : undefined);
      removeAxisTransforms(box.y, transforms, yKeys, originBox ? originBox.y : undefined, sourceBox ? sourceBox.y : undefined);
  }
  
  export { removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removePointDelta };
  //# sourceMappingURL=delta-remove.mjs.map