PsyTask | API Docs
    Preparing search index...

    Function createTimer

    • Create rAF timer

      Parameters

      • shouldStop: (time: number, records: TimerRecords) => boolean

        Return true to stop timer

          • (time: number, records: TimerRecords): boolean
          • Parameters

            • time: number

              Current frame time

            • records: TimerRecords

              History frame times, whose elements represent the start time of each frame that triggers VSync

            Returns boolean

      Returns Timer

      const frame_ms = 16.67;
      const duration = 100;
      const timer = createTimer(
      (time, records) => time - records[0] >= duration - frame_ms / 2,
      );