Skip to content

Commit d4847b1

Browse files
committed
2 parents 5860c95 + 2da322a commit d4847b1

File tree

9 files changed

+87
-13
lines changed

9 files changed

+87
-13
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/babel-plugin-react-native-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"registry": "https://registry.npmjs.org/"
44
},
55
"name": "babel-plugin-react-native-web",
6-
"version": "0.21.0",
6+
"version": "0.21.1",
77
"description": "Babel plugin for React Native for Web",
88
"main": "index.js",
99
"devDependencies": {

packages/react-native-web-docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "react-native-web-docs",
4-
"version": "0.21.0",
4+
"version": "0.21.1",
55
"description": "Documentation website for React Native for Web",
66
"scripts": {
77
"dev": "eleventy --serve",

packages/react-native-web-examples/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"private": true,
33
"name": "react-native-web-examples",
4-
"version": "0.21.0",
4+
"version": "0.21.1",
55
"scripts": {
66
"build": "next build",
77
"dev": "next",
88
"start": "next start"
99
},
1010
"dependencies": {
11-
"babel-plugin-react-native-web": "0.21.0",
11+
"babel-plugin-react-native-web": "0.21.1",
1212
"next": "^12.2.0",
1313
"react": "^18.0.0",
1414
"react-dom": "^18.0.0",
15-
"react-native-web": "0.21.0"
15+
"react-native-web": "0.21.1"
1616
},
1717
"devDependencies": {
1818
"@babel/core": "^7.18.6",

packages/react-native-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"registry": "https://registry.npmjs.org/"
44
},
55
"name": "react-native-web",
6-
"version": "0.21.0",
6+
"version": "0.21.1",
77
"description": "React Native for Web",
88
"module": "dist/index.js",
99
"main": "dist/cjs/index.js",

packages/react-native-web/src/exports/Animated/__tests__/index-test.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import Animated from '..';
1111
import Easing from '../../Easing';
12+
import AnimatedImplementation from '../../../vendor/react-native/Animated/AnimatedImplementation';
1213

1314
const AnimatedInterpolation = Animated.Interpolation;
1415

@@ -329,4 +330,74 @@ describe('Animated', () => {
329330
expect(interpolation(2 / 3)).toBe('rgba(0, 0, 0, 0.667)');
330331
});
331332
});
333+
334+
describe('sequence and loop', () => {
335+
it('supports restarting sequence after it was stopped during execution', () => {
336+
const anim1 = { start: jest.fn(), stop: jest.fn() };
337+
const anim2 = { start: jest.fn(), stop: jest.fn() };
338+
const cb = jest.fn();
339+
340+
const seq = AnimatedImplementation.sequence([anim1, anim2]);
341+
342+
seq.start(cb);
343+
344+
anim1.start.mock.calls[0][0]({ finished: true });
345+
seq.stop();
346+
347+
// anim1 should be finished so anim2 should also start
348+
expect(anim1.start).toHaveBeenCalledTimes(1);
349+
expect(anim2.start).toHaveBeenCalledTimes(1);
350+
351+
seq.start(cb);
352+
353+
// after restart the sequence should resume from the anim2
354+
expect(anim1.start).toHaveBeenCalledTimes(1);
355+
expect(anim2.start).toHaveBeenCalledTimes(2);
356+
});
357+
358+
it('supports restarting sequence after it was finished without a reset', () => {
359+
const anim1 = { start: jest.fn(), stop: jest.fn() };
360+
const anim2 = { start: jest.fn(), stop: jest.fn() };
361+
const cb = jest.fn();
362+
363+
const seq = AnimatedImplementation.sequence([anim1, anim2]);
364+
365+
seq.start(cb);
366+
anim1.start.mock.calls[0][0]({ finished: true });
367+
anim2.start.mock.calls[0][0]({ finished: true });
368+
369+
// sequence should be finished
370+
expect(cb).toBeCalledWith({ finished: true });
371+
372+
seq.start(cb);
373+
374+
// sequence should successfully restart from the anim1
375+
expect(anim1.start).toHaveBeenCalledTimes(2);
376+
expect(anim2.start).toHaveBeenCalledTimes(1);
377+
});
378+
379+
it('restarts sequence normally in a loop if resetBeforeIteration is false', () => {
380+
const anim1 = { start: jest.fn(), stop: jest.fn() };
381+
const anim2 = { start: jest.fn(), stop: jest.fn() };
382+
const seq = AnimatedImplementation.sequence([anim1, anim2]);
383+
384+
const loop = AnimatedImplementation.loop(seq, {
385+
resetBeforeIteration: false
386+
});
387+
388+
loop.start();
389+
390+
expect(anim1.start).toHaveBeenCalledTimes(1);
391+
392+
anim1.start.mock.calls[0][0]({ finished: true });
393+
394+
expect(anim2.start).toHaveBeenCalledTimes(1);
395+
396+
anim2.start.mock.calls[0][0]({ finished: true });
397+
398+
// after anim2 is finished, the sequence is finished,
399+
// hence the loop iteration is finished, so the next iteration starts
400+
expect(anim1.start).toHaveBeenCalledTimes(2);
401+
});
402+
});
332403
});

packages/react-native-web/src/exports/Platform/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Platform = {
1818
return false;
1919
},
2020
get Version(): string {
21-
return "0.0.0"
21+
return '0.0.0';
2222
}
2323
};
2424

packages/react-native-web/src/vendor/react-native/Animated/AnimatedImplementation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ const sequence = function (
318318
current++;
319319

320320
if (current === animations.length) {
321+
// if the start is called, even without a reset, it should start from the beginning
322+
current = 0;
321323
callback && callback(result);
322324
return;
323325
}

packages/react-native-web/src/vendor/react-native/Animated/nodes/AnimatedProps.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class AnimatedProps extends AnimatedNode {
7878
if (this.__isNative && this._animatedView) {
7979
this.__disconnectAnimatedView();
8080
}
81+
this._animatedView = null;
8182
for (const key in this._props) {
8283
const value = this._props[key];
8384
if (value instanceof AnimatedNode) {

0 commit comments

Comments
 (0)