1 line
1.5 KiB
Plaintext
1 line
1.5 KiB
Plaintext
{"version":3,"file":"sync-time.mjs","sources":["../../../src/frameloop/sync-time.ts"],"sourcesContent":["import { MotionGlobalConfig } from \"motion-utils\"\nimport { frameData } from \"./frame\"\n\nlet now: number | undefined\n\nfunction clearTime() {\n now = undefined\n}\n\n/**\n * An eventloop-synchronous alternative to performance.now().\n *\n * Ensures that time measurements remain consistent within a synchronous context.\n * Usually calling performance.now() twice within the same synchronous context\n * will return different values which isn't useful for animations when we're usually\n * trying to sync animations to the same frame.\n */\nexport const time = {\n now: (): number => {\n if (now === undefined) {\n time.set(\n frameData.isProcessing || MotionGlobalConfig.useManualTiming\n ? frameData.timestamp\n : performance.now()\n )\n }\n\n return now!\n },\n set: (newTime: number) => {\n now = newTime\n queueMicrotask(clearTime)\n },\n}\n"],"names":[],"mappings":";;;AAGA,IAAI,GAAuB,CAAA;AAE3B,SAAS,SAAS,GAAA;IACd,GAAG,GAAG,SAAS,CAAA;AACnB,CAAC;AAED;;;;;;;AAOG;AACU,MAAA,IAAI,GAAG;IAChB,GAAG,EAAE,MAAa;AACd,QAAA,IAAI,GAAG,KAAK,SAAS,EAAE;YACnB,IAAI,CAAC,GAAG,CACJ,SAAS,CAAC,YAAY,IAAI,kBAAkB,CAAC,eAAe;kBACtD,SAAS,CAAC,SAAS;AACrB,kBAAE,WAAW,CAAC,GAAG,EAAE,CAC1B,CAAA;SACJ;AAED,QAAA,OAAO,GAAI,CAAA;KACd;AACD,IAAA,GAAG,EAAE,CAAC,OAAe,KAAI;QACrB,GAAG,GAAG,OAAO,CAAA;QACb,cAAc,CAAC,SAAS,CAAC,CAAA;KAC5B;;;;;"} |