request-animation-frame-timeout
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

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).

Package Sidebar

Install

npm i request-animation-frame-timeout

Weekly Downloads

12,568

Version

2.0.4

License

MIT

Unpacked Size

29 kB

Total Files

22

Last publish

Collaborators

  • catamphetamine