1.0.2 • Published 11 months ago

device-rotation-prompt v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

npm version CircleCI npm bundle size NPM docs

Device rotation prompt

The device rotation prompt is the library to show a fullscreen prompt message when device orientation is different than you expect. It is designed to be used in html5 games, but it can be used on any website.

Instalation

Install library using npm npm install device-rotation-prompt --save and import main class into your code base import {DeviceRotationPrompt} from 'device-orientation-prompt';.

Usage

If you do not need to configure and the default style and setting are enough, you can just instantiate the class and you are done.

const prompt = new DeviceRotationPrompt();

and you get

Device rotation prompt demo

If you do not need this functionality anymore, you can destroy it using destroy method.

prompt.destroy();

If you want to configure the behavior and style of the prompt, you can pass the config object during instantiation.

const prompt = new DeviceRotationPrompt({
    orientation: 'landscape',
    backgroundColor: '#000000',
    imageColor: '#ffffff',
    ...
});

The properties are as follows and all are optional.

PropertyDefaultDescription
orientation'landscape'The orientation you want to force, if orientation is different, prompt is showed ('landscape' or 'portrait')
backgroundColor'#000000'Background color of whole prompt
imageColor'#ffffff'Color of device image
imageSize'60vh' for portrait '30vh' for landscapeSize of device image (all css units like 'px', 'em', 'rem', 'vh'...)
hideImagefalseHide/show image
animationDisablefalseEnable/disable image animation
text'Please rotate your device'Description text to show
textColor'#ffffff'Color of description text
textSize'10vh' for portrait '5vh' for landscapeSize of description text (all css units like 'px', 'em', 'rem', 'vh'...)
textFont'\'Arial Black\', \'Arial Bold\', Gadget, sans-serif'Font of description text
hideTextfalseHide/show description text
containerId'promptContainer'Id of whole container prompt
imageId'promptImage'Id of svg image
textId'promptText'Id of container with description text
styleId'promptStyle'Id of style tag, where all styles of this library are defined
zIndexundefinedz-index of whole prompt (number)

Usage in browser

You can also use this library in the browser without compiling using jsDelivr. Import script into HTML file, and you can access classes through the global treeUtils object.

<script src="https://cdn.jsdelivr.net/npm/device-rotation-prompt@1/dist/browser-bundle.min.js"></script>
<script>
    const prompt = new deviceRotationPrompt.DeviceRotationPrompt({orientation: 'landscape'});
</script>

Documentation

For more details and complete documentation check: https://device-rotation-prompt.netlify.app/

License

MIT

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.0.1

11 months ago