Skip to content

Commit

Permalink
[fixed] OverlayTrigger show/hide timeout management
Browse files Browse the repository at this point in the history
  • Loading branch information
taion committed Oct 22, 2015
1 parent d2bcc8e commit 9d5df37
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/OverlayTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ const OverlayTrigger = React.createClass({
componentWillUnmount() {
ReactDOM.unmountComponentAtNode(this._mountNode);
this._mountNode = null;
clearTimeout(this._hoverDelay);
clearTimeout(this._hoverShowDelay);
clearTimeout(this._hoverHideDelay);
},

componentDidUpdate() {
Expand Down Expand Up @@ -226,9 +227,13 @@ const OverlayTrigger = React.createClass({
},

handleDelayedShow() {
if (this._hoverDelay != null) {
clearTimeout(this._hoverDelay);
this._hoverDelay = null;
if (this._hoverHideDelay != null) {
clearTimeout(this._hoverHideDelay);
this._hoverHideDelay = null;
return;
}

if (this.state.isOverlayShown || this._hoverShowDelay != null) {
return;
}

Expand All @@ -240,16 +245,20 @@ const OverlayTrigger = React.createClass({
return;
}

this._hoverDelay = setTimeout(() => {
this._hoverDelay = null;
this._hoverShowDelay = setTimeout(() => {
this._hoverShowDelay = null;
this.show();
}, delay);
},

handleDelayedHide() {
if (this._hoverDelay != null) {
clearTimeout(this._hoverDelay);
this._hoverDelay = null;
if (this._hoverShowDelay != null) {
clearTimeout(this._hoverShowDelay);
this._hoverShowDelay = null;
return;
}

if (!this.state.isOverlayShown || this._hoverHideDelay != null) {
return;
}

Expand All @@ -261,8 +270,8 @@ const OverlayTrigger = React.createClass({
return;
}

this._hoverDelay = setTimeout(() => {
this._hoverDelay = null;
this._hoverHideDelay = setTimeout(() => {
this._hoverHideDelay = null;
this.hide();
}, delay);
},
Expand Down

0 comments on commit 9d5df37

Please sign in to comment.