From 65bf5b16c1e8a3b7d73fd685d0203b2c231274e6 Mon Sep 17 00:00:00 2001 From: SteffeyDev Date: Mon, 12 Nov 2018 18:58:56 -0500 Subject: [PATCH] Potential fix to Issue #21 --- package.json | 2 +- src/Popover.js | 20 ++++++++++---------- src/Utility.js | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 32ba742..d686a3f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-popover-view", - "version": "1.0.13", + "version": "1.0.14", "description": "A component for react-native", "main": "src/index.js", "author": "Peter Steffey (https://github.com/steffeydev)", diff --git a/src/Popover.js b/src/Popover.js index 5291368..11d693d 100644 --- a/src/Popover.js +++ b/src/Popover.js @@ -230,8 +230,8 @@ class Popover extends React.Component { height: displayArea.height }, viewLargerThanDisplayArea: { - width: preferedX < minX, - height: preferedY < minY + width: preferedX < minX - 1, + height: preferedY < minY - 1 } } } @@ -249,8 +249,8 @@ class Popover extends React.Component { } let viewLargerThanDisplayArea = { - height: preferedY < minY, - width: requestedContentSize.width > displayArea.width + height: preferedY < minY - 1, + width: requestedContentSize.width > Math.ceil(displayArea.width) } let viewWidth = viewLargerThanDisplayArea.width ? forcedContentSize.width : requestedContentSize.width; @@ -290,8 +290,8 @@ class Popover extends React.Component { } let viewLargerThanDisplayArea = { - height: preferedY + requestedContentSize.height > displayArea.y + displayArea.height, - width: requestedContentSize.width > displayArea.width + height: preferedY + requestedContentSize.height > Math.ceil(displayArea.y + displayArea.height), + width: requestedContentSize.width > Math.ceil(displayArea.width) } let viewWidth = viewLargerThanDisplayArea.width ? forcedContentSize.width : requestedContentSize.width; @@ -334,8 +334,8 @@ class Popover extends React.Component { } let viewLargerThanDisplayArea = { - height: requestedContentSize.height > displayArea.height, - width: requestedContentSize.width > fromRect.x - displayArea.x - arrowSize.width + height: requestedContentSize.height > Math.ceil(displayArea.height), + width: requestedContentSize.width > Math.ceil(fromRect.x - displayArea.x - arrowSize.width) } let viewWidth = viewLargerThanDisplayArea.width ? forcedContentSize.width : requestedContentSize.width; @@ -378,8 +378,8 @@ class Popover extends React.Component { } let viewLargerThanDisplayArea = { - height: requestedContentSize.height > displayArea.height, - width: requestedContentSize.width > horizontalSpace + height: requestedContentSize.height > Math.ceil(displayArea.height), + width: requestedContentSize.width > Math.ceil(horizontalSpace) } let viewHeight = viewLargerThanDisplayArea.height ? forcedContentSize.height : requestedContentSize.height; diff --git a/src/Utility.js b/src/Utility.js index 89cc37d..0b69488 100644 --- a/src/Utility.js +++ b/src/Utility.js @@ -44,7 +44,7 @@ export function runAfterChange(getFirst, second, func) { checkFunc(); } -export function waitForNewRect(ref, initialRect, onFinish, verticalOffset) { +export function waitForNewRect(ref, initialRect, onFinish, verticalOffset = 0) { runAfterChange(callback => { NativeModules.UIManager.measure(findNodeHandle(ref), (x0, y0, width, height, x, y) => { callback(new Rect(x, y + verticalOffset, width, height));