29 lines
No EOL
1.2 KiB
JavaScript
29 lines
No EOL
1.2 KiB
JavaScript
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
|