@antv/x6-react-components
Version:
React components for building x6 editors
17 lines • 827 B
JavaScript
import { safeWindow } from './executionEnvironment';
let animationFrameTime = 0;
const nativeRequestAnimationFrame = safeWindow((window) => window.requestAnimationFrame || window.webkitRequestAnimationFrame);
export const cancelAnimationFrame = safeWindow((window) => (window.cancelAnimationFrame ||
window.webkitCancelAnimationFrame ||
window.clearTimeout).bind(window));
export const requestAnimationFrame = nativeRequestAnimationFrame
? nativeRequestAnimationFrame.bind(window)
: (callback) => {
const currTime = Date.now();
const timeDelay = Math.max(0, 16 - (currTime - animationFrameTime));
animationFrameTime = currTime + timeDelay;
return window.setTimeout(() => {
callback(Date.now());
}, timeDelay);
};
//# sourceMappingURL=animationFrame.js.map