Gitter migration: Point people to app.gitter.im (rollout pt. 1)
[gitter.git] / public / js / utils / raf.js
blob526034fbf1d6eb7c076c35855bf300e5926b8882
1 'use strict';
3 function shim(callback) {
4   return window.setTimeout(callback, 1000 / 60);
7 function shimCancel(timeoutId) {
8   window.clearTimeout(timeoutId);
11 let nativeRaf;
12 let nativeCancel;
13 if (typeof window !== 'undefined') {
14   nativeRaf =
15     window.requestAnimationFrame ||
16     window.webkitRequestAnimationFrame ||
17     window.mozRequestAnimationFrame;
19   nativeCancel =
20     window.cancelAnimationFrame ||
21     window.webkitCancelAnimationFrame ||
22     window.mozCancelAnimationFrame;
25 module.exports = (nativeRaf && nativeRaf.bind(window)) || shim;
26 module.exports.cancel = (nativeCancel && nativeCancel.bind(window)) || shimCancel;