Skip to content

Commit 005792a

Browse files
committed
Add a configurable option for allowing webview zooming
1 parent 29e8e14 commit 005792a

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

doc/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
- [webViewStyle](#webViewStyle)
4747
- [webViewProps](#webViewProps)
4848
- [forceAndroidAutoplay](#forceAndroidAutoplay)
49+
- [allowWebViewZoom](#allowWebViewZoom)
4950

5051
### Ref functions
5152

@@ -250,6 +251,10 @@ Changes user string to make autoplay work on the iframe player for some android
250251

251252
userAgent string - `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36';`
252253

254+
## allowWebViewZoom
255+
256+
Controls whether the embedded webview allows user to zoom in. Defaults to `false`
257+
253258
# Ref functions
254259

255260
usage -

index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export interface YoutubeIframeProps {
100100
* callback for when the video playback rate changes.
101101
*/
102102
onPlaybackRateChange?: (event: String) => void;
103+
/**
104+
* Flag to decide whether or not a user can zoom the video webview.
105+
*/
106+
allowWebViewZoom?: Boolean;
103107
}
104108

105109
declare const YoutubeIframe: React.SFC<YoutubeIframeProps>;

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ list of available APIs -
8787
- initialPlayerParams
8888
- webViewStyle
8989
- webViewProps
90+
- allowWebViewZoom
9091

9192
### Ref functions
9293

src/PlayerScripts.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ export const MAIN_SCRIPT = (
5757
rel,
5858
start,
5959
},
60+
allowWebViewZoom,
6061
) => `<!DOCTYPE html>
6162
<html>
6263
<head>
63-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
64+
<meta
65+
name="viewport"
66+
content="width=device-width, initial-scale=1.0${allowWebViewZoom ? '' : ', maximum-scale=1'}"
67+
>
6468
<style>
6569
body {
6670
margin: 0;

src/YoutubeIframe.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const YoutubeIframe = (
2828
onReady = _event => {},
2929
playListStartIndex = 0,
3030
initialPlayerParams = {},
31+
allowWebViewZoom = false,
3132
forceAndroidAutoplay = false,
3233
onChangeState = _event => {},
3334
onPlaybackQualityChange = _quality => {},
@@ -171,7 +172,7 @@ const YoutubeIframe = (
171172
style={[styles.webView, webViewStyle]}
172173
mediaPlaybackRequiresUserAction={false}
173174
allowsFullscreenVideo={!initialPlayerParams?.preventFullScreen}
174-
source={{html: MAIN_SCRIPT(videoId, playList, initialPlayerParams)}}
175+
source={{html: MAIN_SCRIPT(videoId, playList, initialPlayerParams, allowWebViewZoom)}}
175176
userAgent={
176177
forceAndroidAutoplay
177178
? Platform.select({android: CUSTOM_USER_AGENT, ios: ''})

0 commit comments

Comments
 (0)