Blame view

天文台pc/tianwentai-ui/node_modules/motion-dom/dist/es/frameloop/sync-time.mjs 924 Bytes
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
  import { MotionGlobalConfig } from 'motion-utils';
  import { frameData } from './frame.mjs';
  
  let now;
  function clearTime() {
      now = undefined;
  }
  /**
   * An eventloop-synchronous alternative to performance.now().
   *
   * Ensures that time measurements remain consistent within a synchronous context.
   * Usually calling performance.now() twice within the same synchronous context
   * will return different values which isn't useful for animations when we're usually
   * trying to sync animations to the same frame.
   */
  const time = {
      now: () => {
          if (now === undefined) {
              time.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming
                  ? frameData.timestamp
                  : performance.now());
          }
          return now;
      },
      set: (newTime) => {
          now = newTime;
          queueMicrotask(clearTime);
      },
  };
  
  export { time };
  //# sourceMappingURL=sync-time.mjs.map