Browse Source

Added scrollEnable tests

Tom Underhill 4 years ago
parent
commit
0b0a815566
1 changed files with 13 additions and 4 deletions
  1. 13
    4
      example/examples/Scrolling.js

+ 13
- 4
example/examples/Scrolling.js View File

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