%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/vacivi36/.trash/vacivitta/node_modules/motion-dom/dist/es/frameloop/
Upload File :
Create Path :
Current File : /home/vacivi36/.trash/vacivitta/node_modules/motion-dom/dist/es/frameloop/sync-time.mjs

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 };

Zerion Mini Shell 1.0