-
Notifications
You must be signed in to change notification settings - Fork 805
/
WebView.js
47 lines (39 loc) · 1009 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
46
47
'use strict';
var React = require('react-native');
var {
View,
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 = {
...View.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;