Git Product home page Git Product logo

cordova-plugin-recheck-screen-orientation's Introduction

cordova-plugin-recheck-screen-orientation

This is a cordova / phonegap plugin which allows you to force a cordova app into a permitted orientation by forcing a re-check of shouldRotateToOrientation.

Example:

Assuming we have an app which has a number of 'pages' and isVideoPage is true when on the video page and false on all other pages

window.shouldRotateToOrientation = function(orientation) {
  if (isVideoPage) {
    if (orientation === 90 || orientation === -90) { // Landscape
      return true;
    }
  } else {
    if (orientation === 180 || orientation === -180) { // Portrait
      return true;
    }
  }
  return false;
}

// Before entering video page:
cordova.recheckScreenOrientation();

// After leaving video page:
cordova.recheckScreenOrientation();

Without plugin:

When navigating from a portrait page to a landscape page (landscape to portrait) the page will display in the wrong orientation. Upon turning the device to the correct orientation the screen will turn and stay in the correct orientation.

With plugin:

When navigating from a portrait page to a landscape page (landscape to portrait) the page will rotate automatically and the screen will only rotate to supported orientations.

OS Support

iOS

Tested on iOS 6 and 7 on the iPhone. If you test on any other devices please create a pull request to update this readme with your findings or submit an issue.

Other platforms

Other platforms may be supported in the future.

Mechanism

iOS

There is no official way to get iOS to recheck its supported orientations so we have to resort to a hack. The plugin adds a modal view to the view hierarchy and then removes it as soon as it as added. This causes iOS to call shouldRotateOrientation internally. This works on all iOS versions tested so far.

cordova-plugin-recheck-screen-orientation's People

Contributors

jrhe avatar sagrawal31 avatar schuetzm avatar

Watchers

 avatar  avatar

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.