Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Width and height incorrect on IOS when orientation changes. #52

Open
GCheung55 opened this issue Nov 21, 2018 · 6 comments
Open

Width and height incorrect on IOS when orientation changes. #52

GCheung55 opened this issue Nov 21, 2018 · 6 comments

Comments

@GCheung55
Copy link
Contributor

GCheung55 commented Nov 21, 2018

I believe #24 introduced a bug. I'm testing against Simulated iPhone X.

Below are widths and heights returned from _currentWidth and _currentHeight methods, respectively.

Portrait:
widths: [375, 375, 375]
heights: [635, 635, 812]

Landscape:
widths: [724, 724, 375]
heights: [375, 325, 812]

Going by the logic in _currentWidth and _currentHeight, the smallest value will always be used returned regardless of orientation. E.g. width will always be 375 and height will always be 325.

My meta viewport content looks like:

<meta name="viewport" content="width=device-width, initial-scale=1">
@GCheung55
Copy link
Contributor Author

@robert-j-webb In your fix, what meta viewport content are you using?

@GCheung55
Copy link
Contributor Author

Reference info: https://stackoverflow.com/questions/1649086/detect-rotation-of-android-phone-in-the-browser-with-javascript/6603537#6603537

The SO above leaves me questioning the reliability of window.screen.width.

@GCheung55
Copy link
Contributor Author

@rwwagner90 @runspired @robert-j-webb any thoughts on this?

I vaguely remember @runspired saying that matchMedia was too aggressive, but wondering if we can leverage its implementation to fix the issue without being as aggressive...?

@RobbieTheWagner
Copy link
Member

@GCheung55 I don't know much about this, off the top of my head. I'm open to proposed solutions.

@GCheung55
Copy link
Contributor Author

I propose to remove the addition of window.screen.width and window.screen.height because those never change on orientation change - they represent the device's screen width and height in portrait mode.

@RobbieTheWagner
Copy link
Member

@GCheung55 I am totally open to whatever solution works for you. Would you mind opening a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants