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

Clear timeout when unmounting. #73

Merged
merged 1 commit into from
Jan 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dist/react-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,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 @@ -337,7 +338,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 @@ -374,7 +375,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 @@ -113,6 +113,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 @@ -277,7 +278,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 @@ -306,7 +307,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