Skip to content

Commit 96669d8

Browse files
committed
add contentScale prop
1 parent 25a7a82 commit 96669d8

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

docs/props.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,13 @@ Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like
280280
### `allowWebViewZoom`
281281

282282
Controls whether the embedded webview allows user to zoom in. Defaults to `false`
283+
284+
---
285+
286+
### `contentScale`
287+
288+
scale factor for initial-scale and maximum-scale in `<meta />` tag on the webpage. Defaults to `1.0`
289+
290+
:::info zoom -
291+
enabling the `allowWebViewZoom` disabled the maximum-scale attribute in the webpage
292+
:::

index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ export interface YoutubeIframeProps {
122122
* Set this React Ref to use ref functions such as getDuration.
123123
*/
124124
ref?: React.MutableRefObject<YoutubeIframeRef | null>;
125+
/**
126+
* scale factor for initial-scale and maximum-scale in
127+
* <meta /> tag on the webpage
128+
*/
129+
contentScale?: Number;
125130
}
126131

127132
export interface YoutubeMeta {

src/PlayerScripts.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export const MAIN_SCRIPT = (
6666
playList,
6767
initialPlayerParams,
6868
allowWebViewZoom,
69+
contentScale,
6970
) => {
7071
const {
7172
end,
@@ -93,12 +94,13 @@ export const MAIN_SCRIPT = (
9394
const showClosedCaptions_s = showClosedCaptions ? 1 : 0;
9495
const list = typeof playList === 'string' ? playList : '';
9596
const listType = typeof playList === 'string' ? 'playlist' : '';
97+
const contentScale_s = typeof contentScale === 'number' ? contentScale : 1.0;
9698

97-
// scale will either be "initial-scale=0.8"
98-
let scale = 'initial-scale=0.8';
99+
// scale will either be "initial-scale=1.0"
100+
let scale = `initial-scale=${contentScale_s}`;
99101
if (allowWebViewZoom) {
100-
// or "initial-scale=0.8, maximum-scale=0.8"
101-
scale += ', maximum-scale=0.8';
102+
// or "initial-scale=0.8, maximum-scale=1.0"
103+
scale += `, maximum-scale=${contentScale_s}`;
102104
}
103105

104106
return `

src/YoutubeIframe.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const YoutubeIframe = (props, ref) => {
2929
webViewStyle,
3030
webViewProps,
3131
playbackRate = 1,
32+
contentScale = 1.0,
3233
onError = _err => {},
3334
onReady = _event => {},
3435
playListStartIndex = 0,
@@ -180,6 +181,7 @@ const YoutubeIframe = (props, ref) => {
180181
playList,
181182
initialPlayerParams,
182183
allowWebViewZoom,
184+
contentScale,
183185
),
184186
}}
185187
userAgent={

0 commit comments

Comments
 (0)