redux-responsive icon indicating copy to clipboard operation
redux-responsive copied to clipboard

Orientation change issue

Open ou-di opened this issue 7 years ago • 9 comments

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

ou-di avatar Jan 19 '18 10:01 ou-di

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

ischoe avatar Jan 22 '18 14:01 ischoe

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 avatar Feb 01 '18 18:02 AlecAivazis

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

AlecAivazis avatar Feb 01 '18 18:02 AlecAivazis

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

ou-di avatar Feb 05 '18 11:02 ou-di

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
    }
  }

JesusADS avatar Jun 11 '18 09:06 JesusADS

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

ghost avatar Jun 11 '18 10:06 ghost

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

AlecAivazis avatar Jun 13 '18 15:06 AlecAivazis

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

JesusADS avatar Jun 13 '18 16:06 JesusADS

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 avatar Aug 14 '18 16:08 jordxn