|
@@ -9,7 +9,7 @@
|
9
|
9
|
*/
|
10
|
10
|
|
11
|
11
|
import React, {Component} from 'react';
|
12
|
|
-import {Text, View} from 'react-native';
|
|
12
|
+import {Button, Text, View} from 'react-native';
|
13
|
13
|
|
14
|
14
|
import WebView from 'react-native-webview';
|
15
|
15
|
|
|
@@ -40,10 +40,14 @@ const HTML = `
|
40
|
40
|
`;
|
41
|
41
|
|
42
|
42
|
type Props = {};
|
43
|
|
-type State = { lastScrollEvent: string };
|
|
43
|
+type State = {
|
|
44
|
+ scrollEnabled: boolean,
|
|
45
|
+ lastScrollEvent: string
|
|
46
|
+};
|
44
|
47
|
|
45
|
48
|
export default class Scrolling extends Component<Props, State> {
|
46
|
49
|
state = {
|
|
50
|
+ scrollEnabled: true,
|
47
|
51
|
lastScrollEvent: ''
|
48
|
52
|
};
|
49
|
53
|
|
|
@@ -55,15 +59,20 @@ export default class Scrolling extends Component<Props, State> {
|
55
|
59
|
source={{html: HTML}}
|
56
|
60
|
automaticallyAdjustContentInsets={false}
|
57
|
61
|
onScroll={this._onScroll}
|
|
62
|
+ scrollEnabled={this.state.scrollEnabled}
|
58
|
63
|
/>
|
59
|
64
|
</View>
|
|
65
|
+ <Button
|
|
66
|
+ title={this.state.scrollEnabled ? 'Scroll enabled' : 'Scroll disabled'}
|
|
67
|
+ onPress={() => this.setState({scrollEnabled: !this.state.scrollEnabled})}
|
|
68
|
+ />
|
60
|
69
|
<Text>Last scroll event:</Text>
|
61
|
70
|
<Text>{this.state.lastScrollEvent}</Text>
|
62
|
71
|
</View>
|
63
|
72
|
);
|
64
|
73
|
}
|
65
|
74
|
|
66
|
|
- _onScroll = info => {
|
67
|
|
- this.setState({ lastScrollEvent: JSON.stringify(info.nativeEvent) });
|
|
75
|
+ _onScroll = event => {
|
|
76
|
+ this.setState({lastScrollEvent: JSON.stringify(event.nativeEvent)});
|
68
|
77
|
}
|
69
|
78
|
}
|