ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
97 lines (93 loc) • 2.92 kB
JavaScript
/**
* @fileoverview added by tsickle
* Generated from: request-animation.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
// tslint:disable: typedef no-invalid-this
/** @type {?} */
const availablePrefixes = ['moz', 'ms', 'webkit'];
/**
* @return {?}
*/
function requestAnimationFramePolyfill() {
/** @type {?} */
let lastTime = 0;
return (/**
* @param {?} callback
* @return {?}
*/
function (callback) {
/** @type {?} */
const currTime = new Date().getTime();
/** @type {?} */
const timeToCall = Math.max(0, 16 - (currTime - lastTime));
/** @type {?} */
const id = setTimeout((/**
* @return {?}
*/
() => {
callback(currTime + timeToCall);
}), timeToCall);
lastTime = currTime + timeToCall;
return id;
});
}
/**
* @return {?}
*/
function getRequestAnimationFrame() {
if (typeof window === 'undefined') {
return (/**
* @return {?}
*/
() => 0);
}
if (window.requestAnimationFrame) {
// https://github.com/vuejs/vue/issues/4465
return window.requestAnimationFrame.bind(window);
}
/** @type {?} */
const prefix = availablePrefixes.filter((/**
* @param {?} key
* @return {?}
*/
key => `${key}RequestAnimationFrame` in window))[0];
return prefix ? ((/** @type {?} */ (window)))[`${prefix}RequestAnimationFrame`] : requestAnimationFramePolyfill();
}
/**
* @param {?} id
* @return {?}
*/
function cancelRequestAnimationFrame(id) {
if (typeof window === 'undefined') {
return null;
}
if (window.cancelAnimationFrame) {
return window.cancelAnimationFrame(id);
}
/** @type {?} */
const prefix = availablePrefixes.filter((/**
* @param {?} key
* @return {?}
*/
key => `${key}CancelAnimationFrame` in window || `${key}CancelRequestAnimationFrame` in window))[0];
return prefix
? (((/** @type {?} */ (window)))[`${prefix}CancelAnimationFrame`] || ((/** @type {?} */ (window)))[`${prefix}CancelRequestAnimationFrame`])
// @ts-ignore
.call(this, id)
: clearTimeout(id);
}
/** @type {?} */
const reqAnimFrame = getRequestAnimationFrame();
/**
* @fileoverview added by tsickle
* Generated from: public-api.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* Generated from: ng-zorro-antd-core-polyfill.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { cancelRequestAnimationFrame, reqAnimFrame };
//# sourceMappingURL=ng-zorro-antd-core-polyfill.js.map