Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add animation when overlayOpacity is zero #275

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 20 additions & 7 deletions components/Overlay/OverlayView.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class OverlayView extends Component {
});
this.state = {
overlayOpacity: new Animated.Value(0),
overlayOpacityStartedZero: false,
}
}

Expand Down Expand Up @@ -69,7 +70,17 @@ export default class OverlayView extends Component {

get overlayOpacity() {
let {overlayOpacity} = this.props;
return (overlayOpacity || overlayOpacity === 0) ? overlayOpacity : Theme.overlayOpacity;
if (overlayOpacity){
return overlayOpacity;
}else if(overlayOpacity === 0){
this.setState({overlayOpacityStartedZero:true});
return overlayOpacity;
}
if(Theme.overlayOpacity === 0){
this.setState({overlayOpacityStartedZero:true});
return Theme.overlayOpacity;
}
return Theme.overlayOpacity;
}

get appearAnimates() {
Expand Down Expand Up @@ -111,12 +122,14 @@ export default class OverlayView extends Component {
disappear(animated = this.props.animated, additionAnimates = null) {
if (animated) {
Animated.parallel(this.disappearAnimates.concat(additionAnimates)).start(e => this.disappearCompleted());
this.state.overlayOpacity.addListener(e => {
if (e.value < 0.01) {
this.state.overlayOpacity.stopAnimation();
this.state.overlayOpacity.removeAllListeners();
}
});
if(!this.state.overlayOpacityStartedZero){
this.state.overlayOpacity.addListener(e => {
if (e.value < 0.01) {
this.state.overlayOpacity.stopAnimation();
this.state.overlayOpacity.removeAllListeners();
}
});
}
} else {
this.disappearCompleted();
}
Expand Down