WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
151384
window.innerWidth seems to return something other than the viewport width
https://bugs.webkit.org/show_bug.cgi?id=151384
Summary
window.innerWidth seems to return something other than the viewport width
Tobi Reif
Reported
2015-11-18 03:56:15 PST
Please load this page
http://tobireif.com/non_site_stuff/copy_of_tobireif_com_startpage_for_webkit_bugreport_innerWidth/
in the iPhone 4s (iOS 9.1) simulator. The "stamp" (circle) should be centered. Change the function getViewportWidth to always return window.innerWidth, then view the page in the iPhone simulator. The contact stamp is off-center (but in eg Firefox with the ~same window size it's centered as intended). I'd like to be able to use the simple version of the function for all browsers & OSs & devices.
Attachments
Add attachment
proposed patch, testcase, etc.
Tobi Reif
Comment 1
2015-11-18 05:10:53 PST
When I load the page in the Android stock browser (uses WebKit?), then rotate, then rotate again/back, the stamp is off-center.
Simon Fraser (smfr)
Comment 2
2015-12-03 16:13:10 PST
innerWidth is indeed changing as the page loads, and doesn't stabilize until after the load event fires.
Simon Fraser (smfr)
Comment 3
2015-12-03 16:13:14 PST
innerWidth is indeed changing as the page loads, and doesn't stabilize until after the load event fires.
Tobi Reif
Comment 4
2016-01-07 04:23:40 PST
I'll try running the adjust-layout func on load. (Related:
https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html
"load": "Deprecated, use pageshow instead." So "pageshow" is to be used instead it seems.)
Tobi Reif
Comment 5
2016-01-07 04:57:13 PST
In an old Dolphin (uses WebKit it seems) on Samsung Galaxy S3 the width still isn't correct. I had to force a redraw using a hack: body.style.display = "none"; setTimeout(actuallyAdjustLayout, 0); function actuallyAdjustLayout() { body.style.display = "block"; // ... }
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug