react-native-popover-view
Advanced tools
Comparing version 1.0.7 to 1.0.8
{ | ||
"name": "react-native-popover-view", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "A <Popover /> component for react-native", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -16,3 +16,3 @@ 'use strict'; | ||
const DEBUG = true; | ||
const DEBUG = false; | ||
@@ -63,7 +63,9 @@ const PLACEMENT_OPTIONS = Object.freeze({ | ||
this.calculateRect(this.props, fromRect => { | ||
if (DEBUG) console.log("setDefaultDisplayArea (inside calculateRect callback) - fromRect: " + JSON.stringify(fromRect)); | ||
if (DEBUG) console.log("setDefaultDisplayArea (inside calculateRect callback) - getDisplayArea(): " + JSON.stringify(this.getDisplayArea())); | ||
if (DEBUG) console.log("setDefaultDisplayArea (inside calculateRect callback) - displayAreaStore: " + JSON.stringify(this.displayAreaStore)); | ||
if (rectChanged(fromRect, this.state.fromRect) | ||
|| rectChanged(this.getDisplayArea(), this.displayAreaStore)) { | ||
this.displayAreaStore = this.getDisplayArea(); | ||
if (DEBUG) console.log("setDefaultDisplayArea (inside calculateRect callback) - fromRect: " + JSON.stringify(fromRect)); | ||
if (DEBUG) console.log("setDefaultDisplayArea (inside calculateRect callback) - getDisplayArea(): " + JSON.stringify(this.displayAreaStore)); | ||
if (DEBUG) console.log("setDefaultDisplayArea (inside calculateRect callback) - Triggering state update"); | ||
this.setState({fromRect}, () => { | ||
@@ -82,2 +84,3 @@ this.handleGeomChange(); | ||
keyboardDidShow(e) { | ||
if (DEBUG) console.log("keyboardDidShow - keyboard height: " + e.endCoordinates.height); | ||
this.shiftForKeyboard(e.endCoordinates.height); | ||
@@ -87,3 +90,6 @@ } | ||
keyboardDidHide() { | ||
this.setState({shiftedDisplayArea: null}, () => this.handleGeomChange()); | ||
if (DEBUG) console.log("keyboardDidHide"); | ||
// On android, the keyboard update causes a default display area change, so no need to manually trigger | ||
this.setState({shiftedDisplayArea: null}, () => isIOS() && this.handleGeomChange()); | ||
} | ||
@@ -143,4 +149,6 @@ | ||
if ((this.props.fromView && !this.state.fromRect) || !this.getDisplayArea() || !this.safeAreaViewReady) { | ||
if (DEBUG) console.log("measureContent - Waiting - requestedContentSize: " + JSON.stringify(requestedContentSize)); | ||
setTimeout(() => this.measureContent(requestedContentSize), 100); | ||
} else { | ||
if (DEBUG) console.log("measureContent - Showing Popover - requestedContentSize: " + JSON.stringify(requestedContentSize)); | ||
let geom = this.computeGeometry({requestedContentSize}); | ||
@@ -500,4 +508,6 @@ this.setState(Object.assign(geom, {requestedContentSize, isAwaitingShow: false}), this.animateIn); | ||
this.calculateRect(nextProps, fromRect => this.setState({fromRect, isAwaitingShow: true, visible: true})); | ||
if (DEBUG) console.log("componentWillReceiveProps - Awaiting popover show"); | ||
} else { | ||
this.animateOut(); | ||
this.animateOut(); | ||
if (DEBUG) console.log("componentWillReceiveProps - Hiding popover"); | ||
} | ||
@@ -546,3 +556,4 @@ } else if (willBeVisible) { | ||
this.updateCount--; | ||
if (DEBUG) console.log("handleGeomChange - Triggering popover move") | ||
let moveTo = new Point(geom.popoverOrigin.x, geom.popoverOrigin.y); | ||
if (DEBUG) console.log("handleGeomChange - Triggering popover move to: " + JSON.stringify(moveTo)) | ||
this.animateTo({ | ||
@@ -552,3 +563,3 @@ values: animatedValues, | ||
scale: 1, | ||
translatePoint: new Point(geom.popoverOrigin.x, geom.popoverOrigin.y), | ||
translatePoint: moveTo, | ||
easing: Easing.inOut(Easing.quad) | ||
@@ -564,3 +575,2 @@ }); | ||
this.keyboardDidHideListener && this.keyboardDidHideListener.remove(); | ||
this.safeAreaViewReady = false; | ||
this.setState({shiftedDisplayArea: null}); | ||
@@ -567,0 +577,0 @@ this.animateTo({ |
@@ -37,11 +37,14 @@ import { Platform, Animated, NativeModules, findNodeHandle, Dimensions } from 'react-native' | ||
export function runAfterChange(getFirst, second, func) { | ||
let interval = setInterval(() => { | ||
let count = 0; // Failsafe so that the interval doesn't run forever | ||
let checkFunc = () => | ||
getFirst(first => { | ||
if (first !== second) { | ||
clearInterval(interval); | ||
func(); | ||
} else if (count < 20) { | ||
count++; | ||
setTimeout(checkFunc, 100); | ||
} | ||
}, 100) | ||
}); | ||
setTimeout(() => clearInterval(interval), 2000); // Failsafe so that the interval doesn't run forever | ||
}); | ||
checkFunc(); | ||
} | ||
@@ -48,0 +51,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114691
1208