forked from race604/ZhiHuDaily-React-Native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebView.js
45 lines (37 loc) · 981 Bytes
/
WebView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
var React = require('react-native');
var {
requireNativeComponent,
PropTypes
} = React;
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
class ObservableWebView extends React.Component {
constructor() {
super();
this._onChange = this._onChange.bind(this);
}
_onChange(event: Event) {
if (!this.props.onScrollChange) {
return;
}
this.props.onScrollChange(event.nativeEvent.ScrollY);
}
render() {
return <RCTWebView {...this.props} onChange={this._onChange} />;
}
}
ObservableWebView.propTypes = {
url: PropTypes.string,
html: PropTypes.string,
css: PropTypes.string,
onScrollChange: PropTypes.func,
};
//
// ObservableWebView.viewConfig = {
// uiViewClassName: 'RCTWebView',
// validAttributes: ReactNativeViewAttributes.RKView
// };
var RCTWebView = requireNativeComponent('RCTWebView', ObservableWebView, {
nativeOnly: {onChange: true}
});
module.exports = ObservableWebView;