Skip to content
This repository has been archived by the owner on Apr 25, 2021. It is now read-only.

Orientation change issue #97

Open
ou-di opened this issue Jan 19, 2018 · 9 comments
Open

Orientation change issue #97

ou-di opened this issue Jan 19, 2018 · 9 comments

Comments

@ou-di
Copy link

ou-di commented Jan 19, 2018

Orientation change value is always one step back. E.g on portrait mode on load the value ist 'portrait'. On first orientation change (from portrait to landscape) nothing happens (should be landscape). On second orientation change (from landscape to portrait) the value is changed to 'landscape'.
Can someone confirm the issue?
I'm using the current release 4.3.5

@ischoe
Copy link

ischoe commented Jan 22, 2018

having the same issue, but only on android mobile phones...

@AlecAivazis
Copy link
Owner

Hey @ou-di @ischoe thanks for reporting this. I'm going to try to reproduce this in the next few weeks. We rely on the orientationchange window event here in order to detect that the orientation actually changed. Could either of you try to register a callback for that event in your projects and see if it actually fires?

Also, is this with react-native or just on the web browser of android phones?

@AlecAivazis
Copy link
Owner

This might be related to #96 although it seems like other users are reporting the exact opposite behavior (works on android, not IOS) 🤔

@ou-di
Copy link
Author

ou-di commented Feb 5, 2018

@AlecAivazis I think the issue is the matchMedia method. To answer your question, it's on the mobile web browser.

@JesusADS
Copy link

Hi! I'm having problems with the orientation also, but my problem is that it's staying in "null". This produce that any other attribute isn't being calculated and stays in "infinity", causing wrong behaviours on mobile.

This is my browser object on first load (happens only like 40% of the times):

  browser: {
    _responsiveState: true,
    lessThan: {
      extraSmall: false,
      small: false,
      medium: false,
      large: false,
      extraLarge: false,
      infinity: false
    },
    greaterThan: {
      extraSmall: true,
      small: true,
      medium: true,
      large: true,
      extraLarge: true,
      infinity: false
    },
    is: {
      extraSmall: false,
      small: false,
      medium: false,
      large: false,
      extraLarge: false,
      infinity: true
    },
    mediaType: 'infinity',
    orientation: null,
    breakpoints: {
      extraSmall: 320,
      small: 640,
      medium: 768,
      large: 960,
      extraLarge: 1200,
      infinity: null
    }
  }

@ghost
Copy link

ghost commented Jun 11, 2018

Hi,
I've the same problem as @JesusADS.

@AlecAivazis
Copy link
Owner

Hey @dmansof, @JesusADS - I'm sorry yuo're running into issues with orientation detection. Can you please tell me what browsers you are using?

@JesusADS
Copy link

Hi @AlecAivazis , i'm using Chrome V67.0.3396.79

@jordxn
Copy link

jordxn commented Aug 14, 2018

Hi, I can replicate this issue on chrome 68 using developer tools device mode.

I think the issue is the following;

"the event [orientationchange] is triggered before the rotation is complete. Therefore, the recorded height reflects the state before the actual orientation change."
https://stackoverflow.com/questions/12452349/mobile-viewport-height-after-orientation-change/26829372#26829372

So this would include the matchMedia() you run in your reducer. So we need to wait a little before firing refreshResponsiveState until the height/width have actually changed. There's a few decent solutions in that stack overflow link.

jordxn pushed a commit to jordxn/redux-responsive that referenced this issue Aug 14, 2018
…tationchange so that matchMedia will produce expected result.
jordxn pushed a commit to jordxn/redux-responsive that referenced this issue Aug 17, 2018
…er orientationchange so that matchMedia will produce expected result."

This reverts commit bf7aa2f.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants