1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import _extends from 'babel-runtime/helpers/extends';
-
-
-
- var iPhoneXPatch = {};
-
- iPhoneXPatch.isIPhoneXPortraitPatchActive = function () {
- return document.documentElement.getAttribute('onsflag-iphonex-portrait') != null && window.innerWidth < window.innerHeight;
- };
-
- iPhoneXPatch.isIPhoneXLandscapePatchActive = function () {
-
- return document.documentElement.getAttribute('onsflag-iphonex-landscape') != null && window.innerWidth >= window.innerHeight;
- };
-
-
- iPhoneXPatch.getSafeAreaLengths = function () {
- var safeAreaLengths = void 0;
- if (iPhoneXPatch.isIPhoneXPortraitPatchActive()) {
- safeAreaLengths = {
- top: 44,
- right: 0,
- bottom: 34,
- left: 0
- };
- } else if (iPhoneXPatch.isIPhoneXLandscapePatchActive()) {
- safeAreaLengths = {
- top: 0,
- right: 44,
- bottom: 21,
- left: 44
- };
- } else {
- safeAreaLengths = {
- top: 0,
- right: 0,
- bottom: 0,
- left: 0
- };
- }
-
- return safeAreaLengths;
- };
-
-
- iPhoneXPatch.getSafeAreaDOMRect = function () {
- var safeAreaRect = void 0;
- if (iPhoneXPatch.isIPhoneXPortraitPatchActive()) {
- safeAreaRect = {
- x: 0,
- y: 44,
- width: window.innerWidth,
- height: window.innerHeight - 78
- };
- } else if (iPhoneXPatch.isIPhoneXLandscapePatchActive()) {
- safeAreaRect = {
- x: 44,
- y: 0,
- width: window.innerWidth - 88,
- height: window.innerHeight - 21
- };
- } else {
- safeAreaRect = {
- x: 0,
- y: 0,
- width: window.innerWidth,
- height: window.innerHeight
- };
- }
-
- return _extends({}, safeAreaRect, {
- left: safeAreaRect.x,
- top: safeAreaRect.y,
- right: safeAreaRect.x + safeAreaRect.width,
- bottom: safeAreaRect.y + safeAreaRect.height
- });
- };
-
- export default iPhoneXPatch;
|