{"id":4269,"url":"https://github.com/inProgress-team/react-native-orientation-controller","last_synced_at":"2025-08-04T01:31:44.696Z","repository":{"id":57338839,"uuid":"45260297","full_name":"inProgress-team/react-native-orientation-controller","owner":"inProgress-team","description":null,"archived":false,"fork":false,"pushed_at":"2017-07-05T12:43:07.000Z","size":74,"stargazers_count":26,"open_issues_count":4,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-26T02:35:29.326Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inProgress-team.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-30T15:43:25.000Z","updated_at":"2023-12-27T04:45:30.000Z","dependencies_parsed_at":"2022-09-16T01:44:39.920Z","dependency_job_id":null,"html_url":"https://github.com/inProgress-team/react-native-orientation-controller","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inProgress-team%2Freact-native-orientation-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inProgress-team%2Freact-native-orientation-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inProgress-team%2Freact-native-orientation-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inProgress-team%2Freact-native-orientation-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inProgress-team","download_url":"https://codeload.github.com/inProgress-team/react-native-orientation-controller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228582487,"owners_count":17940587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:06.399Z","updated_at":"2024-12-07T08:30:25.789Z","avatar_url":"https://github.com/inProgress-team.png","language":"Java","readme":"## react-native-orientation-controller\n\n\u003e A react-native library for obtaining and controlling current device or application orientation\n\nThis library is a fork of [this library by Ken Wheeler](https://github.com/walmartreact/react-native-orientation-listener). We thank him.\n\n###Getting Started\n\n- Run `npm install --save react-native-orientation-controller`\n\n### Install with RNPM\n\n- `npm install -g rnpm`\n- `rnpm link react-native-orientation-controller`\n\n### Or Manual Installation\n\n#### Android\n\nAdd to `android/settings.gradle`:\n\n```\ninclude ':react-native-orientation-controller'\nproject(':react-native-orientation-controller').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation-controller/android')\n```\n\nAdd the compile project line to `android/app/build.gradle` (inside `dependencies`):\n\n```\ndependencies {\n    // ... other content ... \n    compile project(':react-native-orientation-controller')\n}\n```\n\nInside `MainActivity.java` (normally somewhere here `android/app/src/main/java/com/\u003cyour-app-name\u003e/MainActivity.java`)\nadd `import com.inprogress.ReactOrientationController.ReactOrientationController;` and ` new ReactOrientationController(this)`\nlike in the example below\n\n```\nimport com.inprogress.ReactOrientationController.ReactOrientationController; // \u003c\u003c\u003c ADD THIS\n\n/* ... other content ... */\n\n    @Override\n    protected List\u003cReactPackage\u003e getPackages() {\n        return Arrays.\u003cReactPackage\u003easList(\n            new MainReactPackage(),\n            new ReactOrientationController(this) // \u003c\u003c\u003c AND THIS\n            /* ... other packages can be here ... */\n        );\n    }\n\n```\n\n\n### Usage\n\nImport the library:\n\n```javascript\nvar Orientation = require('react-native-orientation-controller');\n```\n\n####rotate(orientation)\n\nThis method will change the current orientation of the device of 90° for parameter=1, 180° for parameter=2, 270° for parameter=3 :\n\n```javascript\ncomponentDidMount(){\n  Orientation.rotate(parameter);\n}\n```\n\n####getOrientation(callback)\n\nThis method will return the current orientation of the device, the current orientation of the application, the device model and the screen size in the form of a callback:\n\n```javascript\ncomponentDidMount(){\n  Orientation.getOrientation(\n    (deviceOrientation, applicationOrientation, device, size) =\u003e {\n      console.log(deviceOrientation, applicationOrientation, device, size);\n    }\n  );\n}\n```\n\n####addListener(callback)\n\nThis method will add a listener that will call the callback anytime the orientation changes:\n\n```javascript\n_setOrientation(deviceOrientation, applicationOrientation, device, size) {\n   console.log(deviceOrientation, applicationOrientation, device, size);\n},\ncomponentDidMount(){\n  this.orientationListener = Orientation.addListener(this._setOrientation);\n}\n```\n\n####removeListener(callback)\n\nThis method removes the listener you added in componentDidMount:\n\n```javascript\ncomponentWillUnmount() {\n  this.orientationListener.remove(); \n}\n```\n\n","funding_links":[],"categories":["Components"],"sub_categories":["UI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FinProgress-team%2Freact-native-orientation-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FinProgress-team%2Freact-native-orientation-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FinProgress-team%2Freact-native-orientation-controller/lists"}