[RN: Animated] Fix delay anims

Summary:
They weren't calling onEnd because of duration: 0 optimiziation.
This commit is contained in:
Spencer Ahrens 2015-07-08 04:17:54 -07:00
parent b3e0a702a7
commit 0d0b4c947b
2 changed files with 27 additions and 0 deletions

View File

@ -172,6 +172,7 @@ class TimingAnimation extends Animation {
var start = () => { var start = () => {
if (this._duration === 0) { if (this._duration === 0) {
this._onUpdate(this._toValue); this._onUpdate(this._toValue);
this.__debouncedOnEnd({finished: true});
} else { } else {
this._startTime = Date.now(); this._startTime = Date.now();
this._animationFrame = window.requestAnimationFrame(this.onUpdate.bind(this)); this._animationFrame = window.requestAnimationFrame(this.onUpdate.bind(this));

View File

@ -279,6 +279,32 @@ describe('Animated Parallel', () => {
}); });
}); });
describe('Animated delays', () => {
it('should call anim after delay in sequence', () => {
var anim = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
var cb = jest.genMockFunction();
Animated.sequence([
Animated.delay(1000),
anim,
]).start(cb);
jest.runAllTimers();
expect(anim.start.mock.calls.length).toBe(1);
expect(cb).not.toBeCalled();
anim.start.mock.calls[0][0]({finished: true});
expect(cb).toBeCalledWith({finished: true});
});
it('should run stagger to end', () => {
var cb = jest.genMockFunction();
Animated.stagger(1000, [
Animated.delay(1000),
Animated.delay(1000),
Animated.delay(1000),
]).start(cb);
jest.runAllTimers();
expect(cb).toBeCalledWith({finished: true});
});
});
describe('Animated Events', () => { describe('Animated Events', () => {
it('should map events', () => { it('should map events', () => {
var value = new Animated.Value(0); var value = new Animated.Value(0);