Allow Animated.parallel to accept empty element in the array
This commit is contained in:
parent
35aa9f3b97
commit
4e33b801ca
|
@ -1177,7 +1177,7 @@ var parallel = function(
|
||||||
}
|
}
|
||||||
|
|
||||||
animations.forEach((animation, idx) => {
|
animations.forEach((animation, idx) => {
|
||||||
animation.start(endResult => {
|
var cb = function(endResult) {
|
||||||
hasEnded[idx] = true;
|
hasEnded[idx] = true;
|
||||||
doneCount++;
|
doneCount++;
|
||||||
if (doneCount === animations.length) {
|
if (doneCount === animations.length) {
|
||||||
|
@ -1189,7 +1189,13 @@ var parallel = function(
|
||||||
if (!endResult.finished && stopTogether) {
|
if (!endResult.finished && stopTogether) {
|
||||||
result.stop();
|
result.stop();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (!animation) {
|
||||||
|
cb({finished: true});
|
||||||
|
} else {
|
||||||
|
animation.start(cb);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,16 @@ describe('Animated Parallel', () => {
|
||||||
expect(cb).toBeCalledWith({finished: true});
|
expect(cb).toBeCalledWith({finished: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('works with an empty element in array', () => {
|
||||||
|
var anim1 = {start: jest.genMockFunction()};
|
||||||
|
var cb = jest.genMockFunction();
|
||||||
|
Animated.parallel([null, anim1]).start(cb);
|
||||||
|
|
||||||
|
expect(anim1.start).toBeCalled();
|
||||||
|
anim1.start.mock.calls[0][0]({finished: true});
|
||||||
|
|
||||||
|
expect(cb).toBeCalledWith({finished: true});
|
||||||
|
});
|
||||||
|
|
||||||
it('parellelizes well', () => {
|
it('parellelizes well', () => {
|
||||||
var anim1 = {start: jest.genMockFunction()};
|
var anim1 = {start: jest.genMockFunction()};
|
||||||
|
|
Loading…
Reference in New Issue