Skip to content

Commit f126b6f

Browse files
committed
add content-scale to remote iframe
1 parent 695698a commit f126b6f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

iframe.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta name="viewport" content="width=device-width, maximum-scale=1.0" />
4+
<meta name="viewport" content="width=device-width," />
55
<style>
66
body {
77
margin: 0;
@@ -43,6 +43,7 @@
4343
controls_s,
4444
cc_lang_pref_s,
4545
contentScale_s,
46+
allowWebViewZoom,
4647
modestbranding_s,
4748
iv_load_policy,
4849
preventFullScreen_s,
@@ -53,6 +54,18 @@
5354
window.ReactNativeWebView.postMessage(JSON.stringify(msg));
5455
}
5556

57+
let metaString = '';
58+
if (contentScale_s) {
59+
metaString += `initial-scale=${contentScale_s}`;
60+
}
61+
62+
if (!allowWebViewZoom) {
63+
metaString += `maximum-scale=${contentScale_s}`;
64+
}
65+
66+
const viewport = document.querySelector('meta[name=viewport]');
67+
viewport.setAttribute('content', 'width=device-width,' + metaString);
68+
5669
var tag = document.createElement('script');
5770
tag.src = 'https://www.youtube.com/iframe_api';
5871
var firstScriptTag = document.getElementsByTagName('script')[0];

src/PlayerScripts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export const MAIN_SCRIPT = (
125125
iv_load_policy,
126126
contentScale_s,
127127
cc_lang_pref_s,
128+
allowWebViewZoom,
128129
modestbranding_s,
129130
preventFullScreen_s,
130131
showClosedCaptions_s,

0 commit comments

Comments
 (0)