Skip to content
This repository was archived by the owner on Apr 9, 2019. It is now read-only.

Commit e841fa6

Browse files
committed
Added additional transitions
1 parent 23cee6f commit e841fa6

File tree

8 files changed

+305
-101
lines changed

8 files changed

+305
-101
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,20 @@ Addtional options
9797
Specify the type of transition:
9898

9999
```js
100-
NavigationController.transitionType = {
100+
NavigationController.Transition.type = {
101101
NONE: 0,
102102
PUSH_LEFT: 1,
103103
PUSH_RIGHT: 2,
104104
PUSH_UP: 3,
105-
PUSH_DOWN: 4
105+
PUSH_DOWN: 4,
106+
COVER_LEFT: 5,
107+
COVER_RIGHT: 6,
108+
COVER_UP: 7,
109+
COVER_DOWN: 8,
110+
REVEAL_LEFT: 9,
111+
REVEAL_RIGHT: 10,
112+
REVEAL_UP: 11,
113+
REVEAL_DOWN: 12
106114
};
107115
```
108116

examples/assets/example.css

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ p {
2424
margin: 0 0 0.2em 0;
2525
}
2626

27+
button {
28+
display: block;
29+
padding: 1em 1.5em;
30+
background-color: transparent;
31+
border: 2px solid white;
32+
border-radius: 4px;
33+
color: white;
34+
font-size: 1em;
35+
font-weight: 300;
36+
outline: none;
37+
}
38+
2739
.ReactNavigationController {
2840
position: relative;
2941
height: 480px;
@@ -39,37 +51,46 @@ p {
3951
right: 0;
4052
bottom: 0;
4153
left: 0;
42-
display: -webkit-flex;
43-
display: -ms-flexbox;
54+
}
55+
56+
.ReactNavigationControllerView {
4457
display: flex;
45-
-webkit-align-items: center;
46-
-ms-flex-align: center;
47-
align-items: center;
4858
}
4959

5060
.ReactNavigationControllerViewContent {
51-
padding: 1em;
5261
color: white;
62+
display: flex;
63+
flex-direction: column;
5364
}
5465

55-
.ReactNavigationControllerViewContent div {
56-
margin: auto;
66+
/* HEADER */
67+
68+
.ReactNavigationControllerViewContent header {
69+
display: flex;
70+
justify-content: space-between;
71+
padding: 0.75em;
5772
}
5873

59-
.ReactNavigationControllerViewContent h1 {
60-
margin: auto;
61-
text-align: center;
74+
.ReactNavigationControllerViewContent header button {
75+
76+
}
77+
78+
/* CONTENT */
79+
80+
.ReactNavigationControllerViewContent section {
81+
flex: 1;
82+
display: flex;
83+
flex-direction: column;
84+
align-items: center;
85+
justify-content: center;
6286
}
6387

64-
.ReactNavigationControllerViewContent button {
88+
.ReactNavigationControllerViewContent section h3 {
6589
display: block;
66-
padding: 1em 1.5em;
90+
margin: 0 auto;
91+
font-size: 2rem;
92+
}
93+
94+
.ReactNavigationControllerViewContent section button {
6795
margin: 1em auto;
68-
background-color: transparent;
69-
border: 2px solid white;
70-
border-radius: 4px;
71-
color: white;
72-
font-size: 1em;
73-
font-weight: 700;
74-
outline: none;
7596
}

examples/src/example.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ class App extends React.Component {
1616
views={[<View />]}
1717
preserveState={true}
1818
transitionTension={10}
19-
transitionFriction={5} />
19+
transitionFriction={6} />
2020
<h2>Multiple Views</h2>
2121
<p>Start with multiple views on the stack</p>
2222
<NavigationController
2323
views={[<View />, <View index={2} />, <View index={3} />]}
2424
preserveState={true}
2525
transitionTension={10}
26-
transitionFriction={5} />
26+
transitionFriction={6} />
2727
</main>
2828
);
2929
}

examples/src/view.jsx

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const React = require('react');
22

3+
const NavigationController = require('../../src/navigation-controller');
4+
const {
5+
Transition
6+
} = NavigationController;
7+
38
const colors = [
49
'#0074D9', '#7FDBFF', '#39CCCC', '#2ECC40', '#FFDC00', '#FF851B', '#FF4136',
510
'#F012BE', '#B10DC9'
@@ -27,35 +32,53 @@ class View extends React.Component {
2732
});
2833
}
2934
onNext() {
30-
this.props.navigationController.pushView(
31-
<View index={this.props.index+1} />
32-
);
35+
const view = <View index={this.props.index+1} />;
36+
this.props.navigationController.pushView(view, {
37+
38+
});
3339
}
3440
onBack() {
35-
this.props.navigationController.popView();
41+
this.props.navigationController.popView({
42+
transition: this.props.modal ? Transition.type.REVEAL_DOWN : Transition.type.PUSH_RIGHT
43+
});
44+
}
45+
onModal() {
46+
const view = <View index={this.props.index+1} modal={true} />;
47+
this.props.navigationController.pushView(view, {
48+
transition: Transition.type.COVER_UP
49+
});
3650
}
3751
render() {
3852
return (
3953
<div
4054
className="ReactNavigationControllerViewContent"
4155
style={{background:this.state.color}}>
42-
<div>
43-
<div>
44-
<h1>View {this.props.index}</h1>
45-
<button onClick={this.incrementCounter.bind(this)}>
46-
Increment Counter ({this.state.counter})
47-
</button>
48-
<button onClick={this.onNext.bind(this)}>Next</button>
49-
{this.renderBackButton()}
50-
</div>
51-
</div>
56+
<header>
57+
{this.renderBackButton()}
58+
{this.renderNextButton()}
59+
</header>
60+
<section>
61+
<h3>View {this.props.index}</h3>
62+
<button onClick={this.incrementCounter.bind(this)}>
63+
Increment Counter ({this.state.counter})
64+
</button>
65+
<button onClick={this.onModal.bind(this)}>
66+
Show Modal
67+
</button>
68+
</section>
5269
</div>
5370
);
5471
}
5572
renderBackButton() {
73+
const text = this.props.modal ? 'Close' : 'Back';
5674
return this.props.index === 1
57-
? null
58-
: <button onClick={this.onBack.bind(this)}>Back</button>;
75+
? <div />
76+
: <button onClick={this.onBack.bind(this)}>{text}</button>;
77+
}
78+
renderNextButton() {
79+
return this.props.modal === true
80+
? <div />
81+
: <button onClick={this.onNext.bind(this)}>Next</button>;
5982
}
6083
}
6184

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-navigation-controller",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "A React view manager similar to UINavigationController",
55
"keywords": [
66
"react",

0 commit comments

Comments
 (0)