1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /**
- * 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
- */
- 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 = window.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
|