From d90cce575c04aa3afbb32cb0b63a8b7066250af6 Mon Sep 17 00:00:00 2001 From: SteffeyDev Date: Sun, 17 Mar 2019 13:41:11 -0400 Subject: [PATCH] Fixing issue when isVisible is made false while the popover is animating in --- package.json | 2 +- src/Popover.js | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 5f085a9..1610a88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-popover-view", - "version": "1.0.17", + "version": "1.0.18", "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 f918b54..472cfa2 100644 --- a/src/Popover.js +++ b/src/Popover.js @@ -630,11 +630,17 @@ class Popover extends React.Component { } this.debug("componentWillReceiveProps - Awaiting popover show"); } else { - if (this.state.showing) - this.animateOut(); - else + if (this.state.visible) { + if (this.state.showing) + this.animateOut(); + else + this.animateOutAfterShow = true; + this.debug("componentWillReceiveProps - Hiding popover"); + } + else { this.props.doneClosingCallback(); - this.debug("componentWillReceiveProps - Hiding popover"); + this.debug("componentWillReceiveProps - Popover never shown"); + } } } else if (willBeVisible) { this.calculateRect(nextProps, fromRect => { @@ -732,7 +738,13 @@ class Popover extends React.Component { scale: 1, translatePoint, easing: Easing.out(Easing.back()), - callback: () => this.setState({showing: true}) + callback: () => { + this.setState({showing: true}); + if (this.animateOutAfterShow) { + this.animateOut(); + this.animateOutAfterShow = false; + } + } }) }