Skip to content

Commit

Permalink
Separate stopOnFocus from close (#37)
Browse files Browse the repository at this point in the history
Even when close is not true, still stop dissappearing on focus

Co-authored-by: Varun A P <[email protected]>
  • Loading branch information
haydster7 and apvarun authored Mar 1, 2020
1 parent 350b777 commit 8505d2a
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/toastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,6 @@
}.bind(this)
);

// Clear timeout while toast is focused
if (this.options.stopOnFocus && this.options.duration > 0) {
var self = this;
// stop countdown
divElement.addEventListener(
"mouseover",
function(event) {
window.clearTimeout(divElement.timeOutValue);
}
)
// add back the timeout
divElement.addEventListener(
"mouseleave",
function() {
divElement.timeOutValue = window.setTimeout(
function() {
// Remove the toast from DOM
self.removeElement(divElement);
},
self.options.duration
)
}
)
}

//Calculating screen width
var width = window.innerWidth > 0 ? window.innerWidth : screen.width;

Expand All @@ -166,6 +141,31 @@
}
}

// Clear timeout while toast is focused
if (this.options.stopOnFocus && this.options.duration > 0) {
const self = this;
// stop countdown
divElement.addEventListener(
"mouseover",
function(event) {
window.clearTimeout(divElement.timeOutValue);
}
)
// add back the timeout
divElement.addEventListener(
"mouseleave",
function() {
divElement.timeOutValue = window.setTimeout(
function() {
// Remove the toast from DOM
self.removeElement(divElement);
},
self.options.duration
)
}
)
}

// Adding an on-click destination path
if (typeof this.options.destination !== "undefined") {
divElement.addEventListener(
Expand Down

0 comments on commit 8505d2a

Please sign in to comment.