Skip to content

Instantly share code, notes, and snippets.

@michelepatrassi
Last active June 14, 2022 07:47
Show Gist options
  • Save michelepatrassi/a51821071fcb1485179e997d65e48821 to your computer and use it in GitHub Desktop.
Save michelepatrassi/a51821071fcb1485179e997d65e48821 to your computer and use it in GitHub Desktop.
Angular universal SSR requestAnimationFrame
// add this code to your server.ts
// implementation credits: https://gist.github.com/paulirish/1579671
global['requestAnimationFrame'] = function(callback, element) {
let lastTime = 0;
const currTime = new Date().getTime();
const timeToCall = Math.max(0, 16 - (currTime - lastTime));
const id = setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
global['cancelAnimationFrame'] = function(id) {
clearTimeout(id);
};
@Liudmyla01
Copy link

Hello!
Can you help me fix this bug?
Screenshot 2022-05-11 at 18 54 45

@Benzilla
Copy link

I am also getting this error - did you find a solution to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment