wishthis/node_modules/rxjs/dist/esm5/internal/observable/dom/animationFrames.js

29 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-04-07 07:06:43 +00:00
import { Observable } from '../../Observable';
import { Subscription } from '../../Subscription';
import { performanceTimestampProvider } from '../../scheduler/performanceTimestampProvider';
import { animationFrameProvider } from '../../scheduler/animationFrameProvider';
export function animationFrames(timestampProvider) {
return timestampProvider ? animationFramesFactory(timestampProvider) : DEFAULT_ANIMATION_FRAMES;
}
function animationFramesFactory(timestampProvider) {
var schedule = animationFrameProvider.schedule;
return new Observable(function (subscriber) {
var subscription = new Subscription();
var provider = timestampProvider || performanceTimestampProvider;
var start = provider.now();
var run = function (timestamp) {
var now = provider.now();
subscriber.next({
timestamp: timestampProvider ? now : timestamp,
elapsed: now - start,
});
if (!subscriber.closed) {
subscription.add(schedule(run));
}
};
subscription.add(schedule(run));
return subscription;
});
}
var DEFAULT_ANIMATION_FRAMES = animationFramesFactory();
//# sourceMappingURL=animationFrames.js.map