react-native-responsive icon indicating copy to clipboard operation
react-native-responsive copied to clipboard

No effect when device is landscape

Open Sam116 opened this issue 8 years ago • 4 comments

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

Sam116 avatar Jun 26 '17 08:06 Sam116

You need to watch for Dimensions API

raarts avatar Jul 06 '17 09:07 raarts

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

vonovak avatar Jul 27 '17 18:07 vonovak

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?

Sam116 avatar Sep 27 '17 13:09 Sam116

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?

BorlandFA avatar Jun 05 '18 08:06 BorlandFA