mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-15 17:31:43 +08:00
24 lines
509 B
JavaScript
24 lines
509 B
JavaScript
import getRequestAnimationFrame, {
|
|
cancelRequestAnimationFrame as caf,
|
|
} from './getRequestAnimationFrame';
|
|
const raf = getRequestAnimationFrame();
|
|
|
|
export const cancelAnimationTimeout = frame => caf(frame.id);
|
|
|
|
export const requestAnimationTimeout = (callback, delay) => {
|
|
const start = Date.now();
|
|
function timeout() {
|
|
if (Date.now() - start >= delay) {
|
|
callback.call();
|
|
} else {
|
|
frame.id = raf(timeout);
|
|
}
|
|
}
|
|
|
|
const frame = {
|
|
id: raf(timeout),
|
|
};
|
|
|
|
return frame;
|
|
};
|