Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bf6cd8
commit cb7813a
Showing
4 changed files
with
126 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
// Node.js polyfills for requestAnimationFrame and cancelAnimationFrame | ||
/* global window, setTimeout, clearTimeout */ | ||
|
||
export function requestAnimationFrame(callback) { | ||
return typeof window !== 'undefined' && window.requestAnimationFrame | ||
? window.requestAnimationFrame(callback) | ||
export function requestAnimationFrame(callback, device = window) { | ||
return typeof device !== 'undefined' && device.requestAnimationFrame | ||
? device.requestAnimationFrame(callback) | ||
: setTimeout(callback, 1000 / 60); | ||
} | ||
|
||
export function cancelAnimationFrame(timerId) { | ||
return typeof window !== 'undefined' && window.cancelAnimationFrame | ||
? window.cancelAnimationFrame(timerId) | ||
export function cancelAnimationFrame(timerId, device = window) { | ||
return typeof device !== 'undefined' && device.cancelAnimationFrame | ||
? device.cancelAnimationFrame(timerId) | ||
: clearTimeout(timerId); | ||
} |