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

screenOrientationAngle is not reliable #9

Open
griable opened this issue Dec 12, 2014 · 4 comments
Open

screenOrientationAngle is not reliable #9

griable opened this issue Dec 12, 2014 · 4 comments

Comments

@griable
Copy link

griable commented Dec 12, 2014

Hi there,

First thank you, you're doing great!

I'm trying to create a controller on mobile for a desktop based experience.

My objective is basically to deduce directions from accelerometer values so if we're tilting the phone left, right, front or back we can move accordingly on the desktop.

Most of the time, it works well. But sometimes, my devices returns miscalibrated values.

It's actually related to screenOrientationAngle returning 0. If I trigger manually an orientation change by moving the device to portrait and move back to landscape, the value gets fixed (something like 90 or 270 is now returned) and the adjustment is right.

I know that those values are based on natives window.screen.orientation or window.screen.orientation.angle and that it's not directly related to Fulltilt.

Do you have an idea of how I could fix it?

I hope I was clear enough!

@richtr
Copy link
Contributor

richtr commented Dec 17, 2014

It seems like when we first set the screen orientation angle from window.screen.orientation or window.screen.orientation.angle that the platform is initially returning zero (or null) when the device is in a non-zero screen orientation angle. That is incorrect platform behaviour in my understanding.

Which device, OS and browser are you currently using? Can you load the following page in the landscape screen orientation and let me know what value it reports?

http://jsfiddle.net/Ldaa8LLk/embedded/result/

@griable
Copy link
Author

griable commented Dec 21, 2014

Thank you very much for your feedback.

I wasn't able to reproduce the issue with the jsfiddle for now since the issue isn't consistent.

Previously I used an iPhone 4 running iOS8 and a Nexus 5 running Lollipop.
I'll give a proper reproduction ASAP.

@dorukeker
Copy link
Contributor

I am not sure if this is related with what you experience. I have seen devices return unexpected values if the compass of the device is not calibrated well. You can try to open the compass app and see if it works as expected. I hope this helps.

@alastaircoote
Copy link

I think I've found the problem here. screenOrientationAngle is set when the library is loaded, but the handleScreenOrientationChange event isn't hooked up until an instance of DeviceOrientation is created.

So, if the orientation has changed between page load and new DeviceOrientation it isn't correct.

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