From a731397486a8ed78928df3bf1dcfd94d2bedb19f Mon Sep 17 00:00:00 2001 From: Brian Sanders Date: Sat, 4 Dec 2021 18:43:53 -0500 Subject: [PATCH] Fixes #2369: Video playback is reset on rotation The viewWillTransition(to:with:) method in WebViewController was introduced to fix #3041, so I added an alternative solution using a resize handler in JS. --- iOS/Article/WebViewController.swift | 7 ------- iOS/Resources/main_ios.js | 11 +++++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index 4f18650ad..4cebc1048 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -80,13 +80,6 @@ class WebViewController: UIViewController { loadWebView() } - - override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { - // We need to reload the webview on the iPhone when rotation happens to clear out any old bad viewport sizes - if traitCollection.userInterfaceIdiom == .phone { - loadWebView() - } - } // MARK: Notifications diff --git a/iOS/Resources/main_ios.js b/iOS/Resources/main_ios.js index 8c62081ee..7c0e56076 100644 --- a/iOS/Resources/main_ios.js +++ b/iOS/Resources/main_ios.js @@ -155,6 +155,17 @@ function postRenderProcessing() { showFeedInspectorSetup(); } +function onResize() { + const meta = document.querySelector("meta[name=viewport]"); + + if (!meta) return; + + const originalContent = meta.content; + meta.setAttribute("content", originalContent + ", maximum-scale=1.0"); + meta.setAttribute("content", originalContent); +} +window.addEventListener("resize", onResize); + function makeHighlightRect({left, top, width, height}, offsetTop=0, offsetLeft=0) { const overlay = document.createElement('a');