diff --git a/Libraries/Animation/Animated/Animated.js b/Libraries/Animation/Animated/Animated.js index fd0809825..e4692d610 100644 --- a/Libraries/Animation/Animated/Animated.js +++ b/Libraries/Animation/Animated/Animated.js @@ -172,6 +172,7 @@ class TimingAnimation extends Animation { var start = () => { if (this._duration === 0) { this._onUpdate(this._toValue); + this.__debouncedOnEnd({finished: true}); } else { this._startTime = Date.now(); this._animationFrame = window.requestAnimationFrame(this.onUpdate.bind(this)); diff --git a/Libraries/Animation/Animated/__tests__/Animated-test.js b/Libraries/Animation/Animated/__tests__/Animated-test.js index bd9ef68e5..f5068dc57 100644 --- a/Libraries/Animation/Animated/__tests__/Animated-test.js +++ b/Libraries/Animation/Animated/__tests__/Animated-test.js @@ -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', () => { it('should map events', () => { var value = new Animated.Value(0);