@react-hookz/web
Version:
React hooks done right, for browser and SSR.
16 lines (15 loc) • 627 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useScreenOrientation = void 0;
var __1 = require("..");
/**
* Checks if screen is in `portrait` or `landscape` orientation.
*
* As `Screen Orientation API` is still experimental and not supported by Safari, this
* hook uses CSS3 `orientation` media-query to check screen orientation.
*/
function useScreenOrientation() {
var matches = (0, __1.useMediaQuery)('(orientation: portrait)');
return typeof matches === 'undefined' ? undefined : matches ? 'portrait' : 'landscape';
}
exports.useScreenOrientation = useScreenOrientation;