request-animation-frame-timeout

setTimeout() via requestAnimationFrame()

Pure Nim score 15/100 · last commit 2024-06-04 · 1 stars · tests present · no docs generated

Summary

Latest Version Unknown
License Unknown
CI Status Failing
Stars 1
Forks 0
Open Issues 0
Last Commit 2024-06-04
Downloads 0
Last Indexed 2026-08-11 05:08

Installation

nimble install request-animation-frame-timeout
choosenim install request-animation-frame-timeout
git clone https://gitlab.com/catamphetamine/request-animation-frame-timeout

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
request-animation-frame-timeout - - - - - - -

README

request-animation-frame-timeout

Rationale

For some weird reason, in Chrome, setTimeout() would lag up to a second (or more) behind. Turns out, Chrome developers have deprecated setTimeout() API entirely without asking anyone. Replacing setTimeout() with requestAnimationFrame() can work around that Chrome bug. The timer-freezing behavior of Chrome is inherently retarded, so this workaround wouldn't be required if they designed their corporate web browser properly.

Use

npm install request-animation-frame-timeout --save
import { setTimeout, clearTimeout } from 'request-animation-frame-timeout'

Warning

requestAnimationFrame() doesn't get called when a web browser tab is not visible (minimized or in background). When a web page goes non-visible, all requestAnimationFrame() timers will be paused until the page is visible again. For this reason, requestAnimationFrame() timers should only be used for user-interface-related stuff (visual transitions, user input timers, etc).