0.1.2 • Published 7 years ago

orient-device v0.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Orient Device

Installation

npm install --save-dev orient-device

Usage 1. Add orient.js file to your project code and initialise it.

<html>
<head></head>
<body>

    ...
    <script type="text/javascript" src="path/to/orient.js"></script>

    <script>
        var options = {
            prefferedOrient: 'landscape',
            text: {
                error: '<p><strong>Whoops</strong> can you please rotate your device <br><em>:)</em></p>',
                color: 'rgba(255, 255, 255, 1)'
            },
            onRotate: function() {
              console.log('rotated');
            },
            onError: function() {
              console.log('error - wrong orientation');
            }
        };
        OrientDevice.init(options);
    </script>
</body>
</html>

Or using webpack

let OrientDevice = require('orient-device');
OrientDevice.init();

Here is a list of options:


Custom Callbacks

onRotate - fires when devices is rotated (also fires initially)

onError - fires when devices is in the wrong orientation (fires initially if its in wrong orientation)