rn-custom-style-sheet
Version:
React Native component to select a specific value from a range of values.
35 lines (34 loc) • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useDeviceOrientation;
var _react = require("react");
var _Reducer = require("../../Reducer");
var _UseDeviceOrientationUtils = require("./UseDeviceOrientationUtils");
var _BreakPoint = require("../../../BreakPoint");
var _UseGeneralScreenResolution = require("../UseGeneralScreenResolution");
function useDeviceOrientation(dispatch, isSupportedOrientation, values, withPortraitBehaviorInLandscapeMode, guideLineLayout, baseSizeLayout) {
(0, _react.useEffect)(() => {
let subscription;
if (isSupportedOrientation) {
subscription = (0, _UseDeviceOrientationUtils.listenOrientationChange)(withPortraitBehaviorInLandscapeMode, screenConfig => {
dispatch({
type: _Reducer.ReducerEventEnum.ChangeResolution,
payload: {
currentBreakpointIndex: (0, _BreakPoint.getCurrentBreakpointIndex)(values, screenConfig.screenResolution.windowWidth),
orientation: screenConfig.orientation,
screenResolution: screenConfig.screenResolution,
generalScreenResolution: (0, _UseGeneralScreenResolution.getGeneralScreenResolution)(screenConfig.screenResolution, guideLineLayout, baseSizeLayout)
}
});
});
}
return () => {
(0, _UseDeviceOrientationUtils.removeOrientationListener)(subscription);
subscription = undefined;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isSupportedOrientation, values, guideLineLayout, baseSizeLayout]);
}
//# sourceMappingURL=UseDeviceOrientation.js.map