Skip to content

Commit

Permalink
Merge pull request #22 from exploreorg/master
Browse files Browse the repository at this point in the history
Add option to allow user zooming in the web view
  • Loading branch information
LonelyCpp authored May 14, 2020
2 parents 29e8e14 + 005792a commit 7eaab50
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions doc/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- [webViewStyle](#webViewStyle)
- [webViewProps](#webViewProps)
- [forceAndroidAutoplay](#forceAndroidAutoplay)
- [allowWebViewZoom](#allowWebViewZoom)

### Ref functions

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

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';`

## allowWebViewZoom

Controls whether the embedded webview allows user to zoom in. Defaults to `false`

# Ref functions

usage -
Expand Down
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export interface YoutubeIframeProps {
* callback for when the video playback rate changes.
*/
onPlaybackRateChange?: (event: String) => void;
/**
* Flag to decide whether or not a user can zoom the video webview.
*/
allowWebViewZoom?: Boolean;
}

declare const YoutubeIframe: React.SFC<YoutubeIframeProps>;
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ list of available APIs -
- initialPlayerParams
- webViewStyle
- webViewProps
- allowWebViewZoom

### Ref functions

Expand Down
6 changes: 5 additions & 1 deletion src/PlayerScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ export const MAIN_SCRIPT = (
rel,
start,
},
allowWebViewZoom,
) => `<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<meta
name="viewport"
content="width=device-width, initial-scale=1.0${allowWebViewZoom ? '' : ', maximum-scale=1'}"
>
<style>
body {
margin: 0;
Expand Down
3 changes: 2 additions & 1 deletion src/YoutubeIframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const YoutubeIframe = (
onReady = _event => {},
playListStartIndex = 0,
initialPlayerParams = {},
allowWebViewZoom = false,
forceAndroidAutoplay = false,
onChangeState = _event => {},
onPlaybackQualityChange = _quality => {},
Expand Down Expand Up @@ -171,7 +172,7 @@ const YoutubeIframe = (
style={[styles.webView, webViewStyle]}
mediaPlaybackRequiresUserAction={false}
allowsFullscreenVideo={!initialPlayerParams?.preventFullScreen}
source={{html: MAIN_SCRIPT(videoId, playList, initialPlayerParams)}}
source={{html: MAIN_SCRIPT(videoId, playList, initialPlayerParams, allowWebViewZoom)}}
userAgent={
forceAndroidAutoplay
? Platform.select({android: CUSTOM_USER_AGENT, ios: ''})
Expand Down

0 comments on commit 7eaab50

Please sign in to comment.