Using UniWebView 4.12.1 on iOS and Android.
We want to fix the width of our website for all devices, so that it has identical appearance regardless of the device size. There is a nice tool in HTML for that:
<meta name="viewport" content="width=320, user-scalable=no"/>
It works smoothly on Android and in the Safari app. But for some reason, it breaks smooth scrolling in UniWebView on iOS. And there's another side effect: the website starts jerking when you scroll pas the edges (like there's some script that tries to prevent bouncing).
If we change width to device-width
it scrolls smoothly again.
So, is there a way to use fixed size viewport with UniWebView on iOS without breaking smooth scrolling?
Update 10.08.2022
It seems that differen widths work smoothly for some Apple devices but break smooth scrolling for the other devices. For example, if I set width=354
:
width=355
This strange problem which seems to be exclusive for iOS webview was solved by:
initial-scale
, minimum-scale
and maximum-scale
Code:
var deviceWidth = window.screen.width;
var appWidth = 360;
var scale = (deviceWidth/appWidth).toFixed(2);
document.write("<meta name='viewport' content='initial-scale=" + scale + ", minimum-scale=" + scale + ", maximum-scale=" + scale + ", user-scalable=no' id='viewportMeta'/>");