Skip to content

Commit

Permalink
fix: release event listners (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeffrie authored May 7, 2020
1 parent e7bea2d commit 7cc1203
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class ReactTooltip extends React.Component {
this.clearTimer();

this.unbindListener();
this.removeScrollListener();
this.removeScrollListener(this.state.currentTarget);
this.unbindWindowEvents();
}

Expand Down Expand Up @@ -573,7 +573,7 @@ class ReactTooltip extends React.Component {
this.removeListenerForTooltipExit();

this.setState({ show: false }, () => {
this.removeScrollListener();
this.removeScrollListener(this.state.currentTarget);
if (isVisible && afterHide) {
afterHide(e);
}
Expand Down Expand Up @@ -604,8 +604,9 @@ class ReactTooltip extends React.Component {
window.addEventListener("scroll", this.hideTooltipOnScroll, isCaptureMode);
}

removeScrollListener() {
window.removeEventListener("scroll", this.hideTooltipOnScroll);
removeScrollListener(currentTarget) {
const isCaptureMode = this.isCapture(currentTarget);
window.removeEventListener("scroll", this.hideTooltipOnScroll, isCaptureMode);
}

// Calculation the position
Expand Down

0 comments on commit 7cc1203

Please sign in to comment.