You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
654 B
27 lines
654 B
2 years ago
|
var Emitter = require('./Emitter');
|
||
|
var safeGet = require('./safeGet');
|
||
|
var screen = window.screen;
|
||
|
exports = {
|
||
|
get: function() {
|
||
|
if (screen) {
|
||
|
var orientation = safeGet(screen, 'orientation.type');
|
||
|
if (orientation) return orientation.split('-').shift();
|
||
|
}
|
||
|
return window.innerWidth > window.innerHeight
|
||
|
? 'landscape'
|
||
|
: 'portrait';
|
||
|
}
|
||
|
};
|
||
|
Emitter.mixin(exports);
|
||
|
window.addEventListener(
|
||
|
'orientationchange',
|
||
|
function() {
|
||
|
setTimeout(function() {
|
||
|
exports.emit('change', exports.get());
|
||
|
}, 200);
|
||
|
},
|
||
|
false
|
||
|
);
|
||
|
|
||
|
module.exports = exports;
|