0.3.0 • Published 9 years ago

uupaa.screenorientationevent.js v0.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

ScreenOrientationEvent.js Build Status

npm

Screen orientation handler.

This module made of WebModule.

Documentation

Browser compatibility

ScreenOrientation.onScreenOrientation.lock
Chrome:o::o:
Chrome for Android:o::o:
Firefox for Android:o::o:
Edge:o::o:
Mobile Safari:o::x:
IE10:x::x:
IE11 (Windows 8.1):x::x:
IE11 (Windows 7):x::x:
Safari:x::x:
Android Browser:x::x:

Browser, NW.js and Electron

<script src="<module-dir>/lib/WebModule.js"></script>
<script src="<module-dir>/lib/ScreenOrientationEvent.js"></script>
<script>

window.onload = function() {
    if (ScreenOrientationEvent.enable) {
        _setBodyColor(ScreenOrientationEvent.orientation());

        ScreenOrientationEvent.on(function(currentOrientation, eventType) {
            console.log(currentOrientation, eventType);

            _setBodyColor(currentOrientation);
        });
    }
};

function _setBodyColor(orientation) {
    var color = "white";
    switch (orientation) {
    case   0: color = "white"; break;
    case  90: color = "red";   break;
    case 180: color = "green"; break;
    case 270: color = "blue";  break;
    }
    document.body.style.backgroundColor = color;
}

</script>
0.3.0

9 years ago

0.2.0

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.1

9 years ago