UNPKG

ng-zorro-antd

Version:

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

58 lines (54 loc) 2.07 kB
/** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ /* eslint-disable 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(); } 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); } const reqAnimFrame = getRequestAnimationFrame(); /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ /** * Generated bundle index. Do not edit. */ export { cancelRequestAnimationFrame, reqAnimFrame }; //# sourceMappingURL=ng-zorro-antd-core-polyfill.mjs.map