Skip to content

Commit f92540b

Browse files
adrianicvMinishlink
authored andcommitted
Add scrollEnabled prop
1 parent 860c373 commit f92540b

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ import WebView from 'WebView'; // don't import from react-native
3838
See [RN's doc](https://facebook.github.io/react-native/docs/webview.html).
3939

4040
Supported props are:
41-
- source
42-
- onMessage
41+
- `source`
42+
- `onMessage`
43+
- `scrollEnabled`
4344

44-
Additional props are:
45+
Additional, web-specific props are:
4546
- `newWindow`: (*boolean*|*{ name: string, features: string}*)
4647
This will open the source in a new window, optionally giving it an [internal name and custom features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open).
4748
By default, the name is `webview` and there are no features set.
4849
This is useful when your target has X-Frame-Options or a no-CORS policy.
4950
It currently only supports a `source` prop with a `method` set to `POST`.
5051
Please feel free to do a PR to support more request types!
52+
- `title`: (*string*) This prop will set the `webview` title.
5153

5254
## Examples
5355
See the [storybook](https://react-native-web-community.github.io/react-native-web-webview/storybook).

src/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ export default class extends Component {
9393
);
9494
}
9595

96-
const { title, source, onLoad } = this.props;
96+
const { title, source, onLoad, scrollEnabled } = this.props;
9797
return (
9898
<iframe
9999
title={title}
100100
src={!source.method ? source.uri : undefined}
101101
srcDoc={this.state.html || source.html}
102-
style={{ width: '100%', height: '100%', border: 0 }}
102+
style={[styles.iframe, !scrollEnabled && styles.noScroll]}
103103
allowFullScreen
104104
allowpaymentrequest="true"
105105
frameBorder="0"
@@ -116,4 +116,12 @@ const styles = StyleSheet.create({
116116
alignItems: 'center',
117117
justifyContent: 'center',
118118
},
119+
iframe: {
120+
width: '100%',
121+
height: '100%',
122+
border: 0,
123+
},
124+
noScroll: {
125+
overflow: 'hidden',
126+
},
119127
});

0 commit comments

Comments
 (0)