@antv/x6-react-components
Version:
React components for building x6 editors
20 lines • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.requestAnimationFrame = exports.cancelAnimationFrame = void 0;
const executionEnvironment_1 = require("./executionEnvironment");
let animationFrameTime = 0;
const nativeRequestAnimationFrame = (0, executionEnvironment_1.safeWindow)((window) => window.requestAnimationFrame || window.webkitRequestAnimationFrame);
exports.cancelAnimationFrame = (0, executionEnvironment_1.safeWindow)((window) => (window.cancelAnimationFrame ||
window.webkitCancelAnimationFrame ||
window.clearTimeout).bind(window));
exports.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