UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

41 lines 6.41 kB
// tslint:disable: typedef no-invalid-this const availablePrefixes = ['moz', 'ms', 'webkit']; function requestAnimationFramePolyfill() { let lastTime = 0; return function (callback) { const currTime = new Date().getTime(); const timeToCall = Math.max(0, 16 - (currTime - lastTime)); const id = setTimeout(() => { callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; }; } function getRequestAnimationFrame() { if (typeof window === 'undefined') { return () => 0; } if (window.requestAnimationFrame) { // https://github.com/vuejs/vue/issues/4465 return window.requestAnimationFrame.bind(window); } const prefix = availablePrefixes.filter(key => `${key}RequestAnimationFrame` in window)[0]; return prefix ? window[`${prefix}RequestAnimationFrame`] : requestAnimationFramePolyfill(); } export function cancelRequestAnimationFrame(id) { if (typeof window === 'undefined') { return null; } if (window.cancelAnimationFrame) { return window.cancelAnimationFrame(id); } const prefix = availablePrefixes.filter(key => `${key}CancelAnimationFrame` in window || `${key}CancelRequestAnimationFrame` in window)[0]; return prefix ? (window[`${prefix}CancelAnimationFrame`] || window[`${prefix}CancelRequestAnimationFrame`]) // @ts-ignore .call(this, id) : clearTimeout(id); } export const reqAnimFrame = getRequestAnimationFrame(); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVxdWVzdC1hbmltYXRpb24uanMiLCJzb3VyY2VSb290IjoiL2hvbWUvdnN0cy93b3JrLzEvcy9jb21wb25lbnRzL2NvcmUvcG9seWZpbGwvIiwic291cmNlcyI6WyJyZXF1ZXN0LWFuaW1hdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSwwQ0FBMEM7QUFDMUMsTUFBTSxpQkFBaUIsR0FBRyxDQUFDLEtBQUssRUFBRSxJQUFJLEVBQUUsUUFBUSxDQUFDLENBQUM7QUFFbEQsU0FBUyw2QkFBNkI7SUFDcEMsSUFBSSxRQUFRLEdBQUcsQ0FBQyxDQUFDO0lB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