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

fix ios orientation change #215

Merged

Conversation

thomasjonas
Copy link
Contributor

Fix for #191 and probably also #180. I fixed it by falling back to window.orientation on ios devices as innerHeight and innerWidth are not updated immediately after the orientation change event is fired. I know this is not the ideal solution as window.orientation is deprecated, but I thought it's at least better than having incorrect results.

Fall back to window.orientation on ios devices as innerHeight and innerWidth are not updated immediately after orientation change
@thomasjonas
Copy link
Contributor Author

Just realised falling back to the resize event in case there is no Screen API available also works. So like this:

if (
  screen.orientation &&
  Object.prototype.hasOwnProperty.call(window, 'onorientationchange')
) {
  orientationEvent = 'orientationchange'
}

@21stcn
Copy link

21stcn commented Sep 23, 2019

Hi there

Could I ask when you're planning on updating the npm release with this change? Not having the orientation class updating on apple device orientation change is a critical problem that arguably undermines the purpose of this module, at least for my needs with conditional responsive css dependant on that class. Just wondering if I need to branch or switch to @media orientation rules or if a release is planned shortly.

Thanks

@thomasjonas
Copy link
Contributor Author

I'm personally using a modified version in my project. Would be great if @matthewhudson chime in. I've done a bit more research and noticed that relying on the resize event is probably the best workaround for this. I've had some problems with older iOS version where window.orientation would return different values.

@matthewhudson matthewhudson merged commit dd0f94c into matthewhudson:master Sep 23, 2019
@matthewhudson
Copy link
Owner

This is fantastic @thomasjonas - thank you! Cutting a new minor release now.

@matthewhudson
Copy link
Owner

matthewhudson commented Sep 23, 2019

@thomasjonas @21stcn Latest version is v0.9.0

Latest version is v0.9.1

@21stcn
Copy link

21stcn commented Sep 24, 2019

Thanks @thomasjonas for the fix and @matthewhudson for the quick update. Orientation class updates as expected now in ipad mini 2 after orientation change. 👍

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

Successfully merging this pull request may close these issues.

None yet

3 participants