Skip to content

Commit

Permalink
Merge pull request #73 from joelburget/master
Browse files Browse the repository at this point in the history
Clear timeout when unmounting.
  • Loading branch information
wwayne committed Jan 21, 2016
2 parents ca9bd32 + 1ff68f4 commit c419662
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions dist/react-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ var ReactTooltip = (function (_Component) {
window.removeEventListener('__react_tooltip_hide_event', this.globalHide);
window.removeEventListener('__react_tooltip_rebuild_event', this.globalRebuild);
window.removeEventListener('resize', this.onWindowResize);
window.clearTimeout(this.delayShowLoop);
};

/* TODO: optimize, bind has been trigger too maany times */
Expand Down Expand Up @@ -338,7 +339,7 @@ var ReactTooltip = (function (_Component) {
var delayShow = _state.delayShow;
var show = _state.show;

clearTimeout(this.delayShowLoop);
window.clearTimeout(this.delayShowLoop);

var delayTime = show ? 0 : parseInt(delayShow, 10);
var eventTarget = e.currentTarget;
Expand Down Expand Up @@ -375,7 +376,7 @@ var ReactTooltip = (function (_Component) {

var delayHide = this.state.delayHide;

clearTimeout(this.delayShowLoop);
window.clearTimeout(this.delayShowLoop);
setTimeout(function () {
_this3.setState({
show: false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"classnames": "^1.2.0",
"react-dom": "^0.14.0"
"react-dom": "0.14.*"
},
"devDependencies": {
"babel": "^5.3.1",
Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default class ReactTooltip extends Component {
window.removeEventListener('__react_tooltip_hide_event', this.globalHide)
window.removeEventListener('__react_tooltip_rebuild_event', this.globalRebuild)
window.removeEventListener('resize', this.onWindowResize)
window.clearTimeout(this.delayShowLoop)
}

/* TODO: optimize, bind has been trigger too maany times */
Expand Down Expand Up @@ -278,7 +279,7 @@ export default class ReactTooltip extends Component {
*/
updateTooltip (e) {
const {delayShow, show} = this.state
clearTimeout(this.delayShowLoop)
window.clearTimeout(this.delayShowLoop)

const delayTime = show ? 0 : parseInt(delayShow, 10)
const eventTarget = e.currentTarget
Expand Down Expand Up @@ -307,7 +308,7 @@ export default class ReactTooltip extends Component {
*/
hideTooltip () {
const {delayHide} = this.state
clearTimeout(this.delayShowLoop)
window.clearTimeout(this.delayShowLoop)
setTimeout(() => {
this.setState({
show: false
Expand Down

0 comments on commit c419662

Please sign in to comment.