GithubHelp home page GithubHelp logo

bionictk / nativescript-screen-orientation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from videospike/nativescript-screen-orientation

0.0 1.0 1.0 8 KB

screen orientation plugin for nativescript

License: MIT License

JavaScript 100.00%

nativescript-screen-orientation's Introduction

A plugin to force change the orientation of a page programmatically in NativeScript. Supports both Android and iOS.


Code Sample

var orientationModule = require("nativescript-screen-orientation");
    
  function pageLoaded(){
        orientationModule.setCurrentOrientation("landscape",function(){
                console.log("landscape orientation set");
            });
        }
       
   function onNavigatingFrom(){
        orientationModule.orientationCleanup();
        }
exports.pageLoad=pageLoaded;
exports.onNavigatingFrom=onNavigatingFrom;

Motivation

To allow force setting of orientation at page - level programmatically.

Installation

tns plugin add nativescript-screen-orientation

API Reference

Allowed orientations are 'portrait', 'landscape' and 'all'.

In order to force an orientation, hook the respective setCurrentOrientation methods at the pageLoad event of page, while make sure the method orientationCleanup is called at the navigatingFrom event of the page.

  • setCurrentOrientation(orientation,callback)

    orientation is a string with possible values 'landscape' , 'portrait' and 'all' . Parameter callback is a function to call once the orientation is set, can be null.

  • orientationCleanup()

    should be called on the navigatingFrom event if setCurrentOrientation is called, if this method is not called, can lead to inconsistent behavior.

Troubleshooting

In iOS , on iPad, if the plugin is not working, it is due to changes in the features supported by iPad. It is required for latest iOS to support multiple apps at the same time by screen sharing, which discourages locking of orientation in a particular mode. In order to make it work on iPad, set the key 'Requires Fullscreen' in xCode under app settings.

nativescript-screen-orientation's People

Contributors

basumeet avatar bathejasumeet avatar bionictk avatar

Watchers

 avatar

Forkers

argonjs

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.