function afterNextFrame(callback) {
	const done = () => {
		clearTimeout(timeout);
		if (HAS_RAF) cancelAnimationFrame(raf);
		setTimeout(callback);
	};
	const timeout = setTimeout(done, RAF_TIMEOUT);

	let raf;
	if (HAS_RAF) {
		raf = requestAnimationFrame(done);
	}
}
Schedule a callback to be invoked after the browser has a chance to paint a new frame.
Do this by combining requestAnimationFrame (rAF) + setTimeout to invoke a callback after
the next browser frame.

Also, schedule a timeout in parallel to the the rAF to ensure the callback is invoked
even if RAF doesn't fire (for example if the browser tab is not visible)

@param {() => void} callback