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

No effect when device is landscape #7

Open
Sam116 opened this issue Jun 26, 2017 · 4 comments
Open

No effect when device is landscape #7

Sam116 opened this issue Jun 26, 2017 · 4 comments

Comments

@Sam116
Copy link

Sam116 commented Jun 26, 2017

Using MediaQueryDebug to watch my device params. When i invert my device to landscape, window params not change. So when i use он my tablet(1280*720), in landscape mode it show me same as in portraint. Did i do something wrong?

@raarts
Copy link

raarts commented Jul 6, 2017

You need to watch for Dimensions API

@vonovak
Copy link

vonovak commented Jul 27, 2017

I thought this would already be built-in! Without that, it doesn't make much sense

@Sam116
Copy link
Author

Sam116 commented Sep 27, 2017

I create this thing:

<MediaQuery minDeviceWidth={this.state.minDeviceWidth}></MediaQuery> /* landscape version*/

<MediaQuery maxDeviceWidth={this.state.maxDeviceWidth}></MediaQuery> /* portrait  version*/

And i change minDeviceWidth, maxDeviceWidth on orientationchange(it works), but MediaQuery does not rebuild, how can i force rerender?

@BorlandFA
Copy link

BorlandFA commented Jun 5, 2018

I was having the same issue than @vonovak and I strongly agree that it makes no sense if that is not built-in. I am not talking about live changes on dimensions but at least static ones (ie: starting the app already in landscape mode).

I was investigating a bit more and I found what causes the module to apply always portrait dimensions:

In lib/api/utils/device.js the device width and hieght are defined as follows:
static dpWidth = Math.min(Dimensions.get("window").width, Dimensions.get("window").height)
static dpHeight = Math.max(Dimensions.get("window").width, Dimensions.get("window").height)

That is, from my point of view, completely wrong since then your width is always the small one even when using your device in landscape. Replaching those lines by the default window width and height would make the app to work as expected.

static dpWidth = Dimensions.get("window").width
static dpHeight = Dimensions.get("window").height

@adbayb @raarts What are you thoughts on that?

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

4 participants