Skip to content

Commit 99bbd4a

Browse files
committed
Merge branch 'oss-sync/master' into HEAD
2 parents bac60f5 + 758dd0d commit 99bbd4a

Some content is hidden

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

44 files changed

+1401
-686
lines changed

Examples/SampleApp/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
24+
# node.js
25+
#
26+
node_modules/
27+
npm-debug.log
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/**
2+
* The examples provided by Facebook are for non-commercial testing and
3+
* evaluation purposes only.
4+
*
5+
* Facebook reserves all rights not expressly granted.
6+
*
7+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9+
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
10+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
11+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
12+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13+
*
14+
* @flow
15+
*/
16+
'use strict';
17+
18+
var React = require('react-native');
19+
var {
20+
StyleSheet,
21+
PanResponder,
22+
View,
23+
} = React;
24+
25+
var CIRCLE_SIZE = 80;
26+
var CIRCLE_COLOR = 'blue';
27+
var CIRCLE_HIGHLIGHT_COLOR = 'green';
28+
29+
30+
var NavigatorIOSExample = React.createClass({
31+
32+
statics: {
33+
title: 'PanResponder Sample',
34+
description: 'Basic gesture handling example',
35+
},
36+
37+
_panResponder: {},
38+
_previousLeft: 0,
39+
_previousTop: 0,
40+
_circleStyles: {},
41+
circle: (null : ?{ setNativeProps(props: Object): void }),
42+
43+
componentWillMount: function() {
44+
this._panResponder = PanResponder.create({
45+
onStartShouldSetPanResponder: this._handleStartShouldSetPanResponder,
46+
onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder,
47+
onPanResponderGrant: this._handlePanResponderGrant,
48+
onPanResponderMove: this._handlePanResponderMove,
49+
onPanResponderRelease: this._handlePanResponderEnd,
50+
onPanResponderTerminate: this._handlePanResponderEnd,
51+
});
52+
this._previousLeft = 20;
53+
this._previousTop = 84;
54+
this._circleStyles = {
55+
left: this._previousLeft,
56+
top: this._previousTop,
57+
};
58+
},
59+
60+
componentDidMount: function() {
61+
this._updatePosition();
62+
},
63+
64+
render: function() {
65+
return (
66+
<View
67+
style={styles.container}>
68+
<View
69+
ref={(circle) => {
70+
this.circle = circle;
71+
}}
72+
style={styles.circle}
73+
{...this._panResponder.panHandlers}
74+
/>
75+
</View>
76+
);
77+
},
78+
79+
_highlight: function() {
80+
this.circle && this.circle.setNativeProps({
81+
backgroundColor: CIRCLE_HIGHLIGHT_COLOR
82+
});
83+
},
84+
85+
_unHighlight: function() {
86+
this.circle && this.circle.setNativeProps({
87+
backgroundColor: CIRCLE_COLOR
88+
});
89+
},
90+
91+
_updatePosition: function() {
92+
this.circle && this.circle.setNativeProps(this._circleStyles);
93+
},
94+
95+
_handleStartShouldSetPanResponder: function(e: Object, gestureState: Object): boolean {
96+
// Should we become active when the user presses down on the circle?
97+
return true;
98+
},
99+
100+
_handleMoveShouldSetPanResponder: function(e: Object, gestureState: Object): boolean {
101+
// Should we become active when the user moves a touch over the circle?
102+
return true;
103+
},
104+
105+
_handlePanResponderGrant: function(e: Object, gestureState: Object) {
106+
this._highlight();
107+
},
108+
_handlePanResponderMove: function(e: Object, gestureState: Object) {
109+
this._circleStyles.left = this._previousLeft + gestureState.dx;
110+
this._circleStyles.top = this._previousTop + gestureState.dy;
111+
this._updatePosition();
112+
},
113+
_handlePanResponderEnd: function(e: Object, gestureState: Object) {
114+
this._unHighlight();
115+
this._previousLeft += gestureState.dx;
116+
this._previousTop += gestureState.dy;
117+
},
118+
});
119+
120+
var styles = StyleSheet.create({
121+
circle: {
122+
width: CIRCLE_SIZE,
123+
height: CIRCLE_SIZE,
124+
borderRadius: CIRCLE_SIZE / 2,
125+
backgroundColor: CIRCLE_COLOR,
126+
position: 'absolute',
127+
left: 0,
128+
top: 0,
129+
},
130+
container: {
131+
flex: 1,
132+
paddingTop: 64,
133+
},
134+
});
135+
136+
module.exports = NavigatorIOSExample;

Examples/UIExplorer/UIExplorerList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ var COMPONENTS = [
3939
require('./ListViewExample'),
4040
require('./ListViewPagingExample'),
4141
require('./MapViewExample'),
42-
require('./NavigatorIOSExample'),
4342
NavigatorExample,
43+
require('./NavigatorIOSExample'),
4444
require('./PickerIOSExample'),
4545
require('./ScrollViewExample'),
4646
require('./SliderIOSExample'),
@@ -64,10 +64,10 @@ var APIS = [
6464
require('./GeolocationExample'),
6565
require('./LayoutExample'),
6666
require('./NetInfoExample'),
67+
require('./PanResponderExample'),
6768
require('./PointerEventsExample'),
6869
require('./PushNotificationIOSExample'),
6970
require('./StatusBarIOSExample'),
70-
require('./ResponderExample'),
7171
require('./TimerExample'),
7272
require('./VibrationIOSExample'),
7373
];

0 commit comments

Comments
 (0)