File size: 1,172 Bytes
bc20498 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import { Subscription } from '../Subscription';
export const animationFrameProvider = {
schedule(callback) {
let request = requestAnimationFrame;
let cancel = cancelAnimationFrame;
const { delegate } = animationFrameProvider;
if (delegate) {
request = delegate.requestAnimationFrame;
cancel = delegate.cancelAnimationFrame;
}
const handle = request((timestamp) => {
cancel = undefined;
callback(timestamp);
});
return new Subscription(() => cancel === null || cancel === void 0 ? void 0 : cancel(handle));
},
requestAnimationFrame(...args) {
const { delegate } = animationFrameProvider;
return ((delegate === null || delegate === void 0 ? void 0 : delegate.requestAnimationFrame) || requestAnimationFrame)(...args);
},
cancelAnimationFrame(...args) {
const { delegate } = animationFrameProvider;
return ((delegate === null || delegate === void 0 ? void 0 : delegate.cancelAnimationFrame) || cancelAnimationFrame)(...args);
},
delegate: undefined,
};
//# sourceMappingURL=animationFrameProvider.js.map |