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

Media queries always assume initial device orientation on Android #13

Closed
amarchen opened this issue May 25, 2016 · 2 comments
Closed

Media queries always assume initial device orientation on Android #13

amarchen opened this issue May 25, 2016 · 2 comments

Comments

@amarchen
Copy link

There is a known issue with Dimensions in Android that cause it to report wrong values. I guess it might be different on different devices, in my Galaxy S5 Mini running Android 5 it always gets stuck with the values app had on launch (e.g. if you start in Portrait, dimensions will be stating narrow screen width forever, even if you rotate the device). Naturally media queries relying on Dimensions do not work properly then. I think I've heard of some similar issues on iOS, but as for Android they are present for sure.

The proper way for fetching the screen size seems to use Android's native DisplayMetrics, there is even an npm module doing it - https://www.npmjs.com/package/react-native-extra-dimensions-android (maybe react-native-extended-stylesheet could depend on this one?).

Another option for tracking the real screen size (that I am using in my app at the moment) is to have one View that takes the whole screen and watch for its onLayout event - its parameters seem to deliver real view size quite reliably. That is useless for react-native-extended-stylesheet at the moment, but possibly you could allow overriding the default dimensions with whatever clients wants e.g. via .build(forcedCurrentDimensions)?

P.S.
Sorry if I am producing too many issues, @vitalets You made an awesome module that simplifies styling for the different devices a lot, so I am reporting what I discover when getting it into use.

@vitalets
Copy link
Owner

Answered here: #9 (comment)

After supporting orientation change it will be fixed. Looks like listening onLayout is the best option without any dependencies.

PS: never mind! You input is very useful! 👍 Feel free to post in case of any other issues and ideas!

@vitalets
Copy link
Owner

vitalets commented Jul 4, 2016

closing this in favor of #9

@vitalets vitalets closed this as completed Jul 4, 2016
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