Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 71a2ee4

Browse files
authored
Merge pull request #138 from tpucci/transitions
Transitions
2 parents eb66b65 + 3c3440f commit 71a2ee4

50 files changed

Lines changed: 1646 additions & 123 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

__mocks__/react.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/Roadmap.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ route: /roadmap
77

88
If there is a real interest on `react-gondola` and its phylosophy, I might add support for the following features:
99

10-
- go back event listener
11-
- transitions
10+
import { StrikeThrough } from "./components/StrikeThrough";
11+
12+
- <StrikeThrough>go back event listener</StrikeThrough> 🎉 Done !
13+
- <StrikeThrough>transitions</StrikeThrough> 🎉 Done !
1214
- navigation gestures
1315

1416
Tweet me some encouragements 😁 and star the repo !

docs/components/StrikeThrough.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { Text } from 'react-native';
3+
4+
export function StrikeThrough(props: { children: string }) {
5+
return (
6+
<Text
7+
style={{
8+
textDecorationLine: 'line-through',
9+
textDecorationStyle: 'solid'
10+
}}
11+
>
12+
{props.children}
13+
</Text>
14+
);
15+
}

docs/guides/Transitions.mdx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: Transitions
3+
menu: Guides
4+
route: /guides/transitions
5+
---
6+
7+
# Transitions
8+
9+
In order to use transitions between two screens, simply add the `Transitioner` key to your stops.
10+
11+
## Basic example
12+
13+
```ts
14+
import React from "react";
15+
import { createCanal } from "react-gondola";
16+
import { SildeLeft } from "react-gondola/transitions";
17+
import { FirstName } from "./FirstName";
18+
import { LastName } from "./LastName";
19+
20+
const SignInCanal = createCanal([
21+
{ name: "firstName", Component: FirstName },
22+
{ name: "lastName", Component: LastName, Transitioner: SildeLeft }
23+
]);
24+
```
25+
26+
## Available transitioners
27+
28+
| Transitioner | Import | transition |
29+
| :-------------------------------------------------------------------: | ---------------------------------------------------------- | :--------------------------------------------------: |
30+
| `SildeLeft` | `import { SildeLeft } from "react-gondola/transitions";` | ![Slide Left transition](./assets/slideLeft.gif) |
31+
| `SildeUp` | `import { SildeUp } from "react-gondola/transitions";` | ![Slide Up transition](./assets/slideUp.gif) |
32+
| `RotateCrazy` (⚠️ experimental: this might be removed without notice) | `import { RotateCrazy } from "react-gondola/transitions";` | ![Rotate Crazy transition](./assets/rotateCrazy.gif) |
33+
34+
## Create your own transitioner
35+
36+
You can create your own transitioner if the one availables does not fit your needs ! Get some inspiration by looking at `SlideLeft` source code and get started !
37+
38+
1. Your transitioner need to extend `TransitionComponent` (imported from `react-gondola/transitions`).
39+
2. Your transitioner will receive a `directionForward` prop. If true, your transitioner need to play the transition forward. Else, it need to play the transition backward.
40+
3. (Optionnal but recommended) If you use jest, you can test your component using `describeTransitioner` from `react-gondola/transitions/describeTransitioner`
41+
42+
⚠️ If you use jest and want to test you Transitioner wihch uses `react-native-reanimated`, make sure you correctly mocked `react-native-reanimated`.
43+
44+
```js
45+
// in your jest setup file, use the following
46+
47+
jest.mock("react-native-reanimated/src/ReanimatedEventEmitter");
48+
jest.mock("react-native-reanimated/src/ReanimatedModule", () => ({
49+
configureNativeProps: () => {},
50+
connectNodes: () => {},
51+
disconnectNodes: () => {},
52+
createNode: () => {},
53+
configureProps: () => {},
54+
getValue: () => {},
55+
dropNode: () => {}
56+
}));
57+
jest.mock("react-native-reanimated/src/derived/evaluateOnce");
58+
jest.mock("react-native-reanimated/src/core/AnimatedProps");
59+
```

docs/guides/assets/rotateCrazy.gif

458 KB
Loading

docs/guides/assets/slideLeft.gif

364 KB
Loading

docs/guides/assets/slideUp.gif

280 KB
Loading

doczrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
menu: [
77
'Welcome',
88
'Getting Started',
9+
{ name: 'Guides', menu: ['Transitions'] },
910
'Example',
1011
'Contribute',
1112
'Roadmap',
@@ -16,6 +17,7 @@ module.exports = {
1617
config.resolve.alias = Object.assign({}, config.resolve.alias, {
1718
'react-native$': 'react-native-web',
1819
'react-gondola$': path.resolve(__dirname, 'src/index.ts'), // eslint-disable-line
20+
'react-gondola/transitions$': path.resolve(__dirname, 'src/transitions/index.ts'), // eslint-disable-line
1921
});
2022
return config;
2123
},

example/android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ android {
138138
}
139139

140140
dependencies {
141+
implementation project(':react-native-reanimated')
141142
implementation fileTree(dir: "libs", include: ["*.jar"])
142143
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
143144
implementation "com.facebook.react:react-native:+" // From node_modules

example/android/app/src/main/java/com/example/MainApplication.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Application;
44

55
import com.facebook.react.ReactApplication;
6+
import com.swmansion.reanimated.ReanimatedPackage;
67
import com.facebook.react.ReactNativeHost;
78
import com.facebook.react.ReactPackage;
89
import com.facebook.react.shell.MainReactPackage;
@@ -22,7 +23,8 @@ public boolean getUseDeveloperSupport() {
2223
@Override
2324
protected List<ReactPackage> getPackages() {
2425
return Arrays.<ReactPackage>asList(
25-
new MainReactPackage()
26+
new MainReactPackage(),
27+
new ReanimatedPackage()
2628
);
2729
}
2830

0 commit comments

Comments
 (0)