Giter Site home page Giter Site logo

Comments (4)

Fsarmento avatar Fsarmento commented on June 3, 2024 1

I having the same issue.

addOrientationListener has to params: orientation and deviceOrientation. orientation seems to be returning the previews orientation, while deviceOrientation is returning the correct orientation.

Btw, getOrientation also have the same two params (orientation and deviceOrientation). I am getting the correct orientation on orientation and deviceOrientation is alwais undefined.

EDIT:

I was also having issue #8 . After enabling the flag "Requires full screen" in the Target General settings (Deployment info), addOrientationListener started returning the correct orientation in the first parameter (both parameters orientation and deviceOrientation now return the same thing)

from react-native-orientation-locker.

wonday avatar wonday commented on June 3, 2024 1

@Fsarmento
thank you, I have fixed sample codes.

from react-native-orientation-locker.

wonday avatar wonday commented on June 3, 2024

orientation is the UI orientation, if you locked, it will not changed when rotating device.
deviceOrientation is the real device orientation, if you locked, it still can return current orientation of device.
You said deviceOrientation is alwais undefined,
can you tell me which platform happened? android or iOS?

from react-native-orientation-locker.

Fsarmento avatar Fsarmento commented on June 3, 2024

I guess it is expected to be undefined... I was misled by the example in the README.md file:

  //get current orientation
   /*
   Orientation.getOrientation((orientation,deviceOrientation)=> {
     console.log("Current UI Orientation: ", orientation);
     console.log("Current Device Orientation: ", deviceOrientation);
   });
   */

However, a few lines below the definition of the getOrientation method shows that the callback only have one parameter. To get the device orientation there is the getDeviceOrientation.

getOrientation(function(orientation))
getDeviceOrientation(function(orientation))

Everything works as you explained πŸ‘

from react-native-orientation-locker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.