ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
81 lines • 6.87 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
// tslint:disable:no-any typedef no-invalid-this
/** @type {?} */
var availablePrefixes = ['moz', 'ms', 'webkit'];
/**
* @return {?}
*/
function requestAnimationFramePolyfill() {
/** @type {?} */
var lastTime = 0;
return (/**
* @param {?} callback
* @return {?}
*/
function (callback) {
/** @type {?} */
var currTime = new Date().getTime();
/** @type {?} */
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
/** @type {?} */
var id = setTimeout((/**
* @return {?}
*/
function () {
callback(currTime + timeToCall);
}), timeToCall);
lastTime = currTime + timeToCall;
return id;
});
}
/**
* @return {?}
*/
function getRequestAnimationFrame() {
if (typeof window === 'undefined') {
return (/**
* @return {?}
*/
function () { return 0; });
}
if (window.requestAnimationFrame) {
// https://github.com/vuejs/vue/issues/4465
return window.requestAnimationFrame.bind(window);
}
/** @type {?} */
var prefix = availablePrefixes.filter((/**
* @param {?} key
* @return {?}
*/
function (key) { return key + "RequestAnimationFrame" in window; }))[0];
return prefix ? ((/** @type {?} */ (window)))[prefix + "RequestAnimationFrame"] : requestAnimationFramePolyfill();
}
/**
* @param {?} id
* @return {?}
*/
export function cancelRequestAnimationFrame(id) {
if (typeof window === 'undefined') {
return null;
}
if (window.cancelAnimationFrame) {
return window.cancelAnimationFrame(id);
}
/** @type {?} */
var prefix = availablePrefixes.filter((/**
* @param {?} key
* @return {?}
*/
function (key) { return 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 {?} */
export var reqAnimFrame = getRequestAnimationFrame();
//# sourceMappingURL=data:application/json;base64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