You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

23 lines
567 B

import getRequestAnimationFrame, { cancelRequestAnimationFrame as caf } from './getRequestAnimationFrame';
var raf = getRequestAnimationFrame();
export var cancelAnimationTimeout = function cancelAnimationTimeout(frame) {
return caf(frame.id);
};
export var requestAnimationTimeout = function requestAnimationTimeout(callback, delay) {
var start = Date.now();
function timeout() {
if (Date.now() - start >= delay) {
callback.call();
} else {
frame.id = raf(timeout);
}
}
var frame = {
id: raf(timeout)
};
return frame;
};