toastify-js
Advanced tools
Comparing version 1.4.0 to 1.5.0
{ | ||
"name": "toastify-js", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Toastify is a lightweight, vanilla JS toast notification library.", | ||
@@ -5,0 +5,0 @@ "main": "./src/toastify.js", |
@@ -6,3 +6,3 @@ # Toastify | ||
[![toastify-js](https://img.shields.io/badge/toastify--js-1.4.0-brightgreen.svg)](https://www.npmjs.com/package/toastify-js) | ||
[![toastify-js](https://img.shields.io/badge/toastify--js-1.5.0-brightgreen.svg)](https://www.npmjs.com/package/toastify-js) | ||
@@ -9,0 +9,0 @@ Toastify is a lightweight, vanilla JS toast notification library. |
/*! | ||
* Toastify js 1.4.0 | ||
* Toastify js 1.5.0 | ||
* https://github.com/apvarun/toastify-js | ||
@@ -21,3 +21,3 @@ * @license MIT licensed | ||
// Library version | ||
version = "1.4.0"; | ||
version = "1.5.0"; | ||
@@ -40,2 +40,4 @@ // Defining the prototype of the object | ||
this.toastElement = null; | ||
// Validating the options | ||
@@ -122,3 +124,3 @@ this.options.text = options.text || "Hi there!"; // Display message | ||
// Clear timeout while toast is focused | ||
if (this.options.stopOnFocus) { | ||
if (this.options.stopOnFocus && this.options.duration > 0) { | ||
const self = this; | ||
@@ -129,3 +131,3 @@ // stop countdown | ||
function(event) { | ||
window.clearTimeout(event.target.timeOutValue); | ||
window.clearTimeout(divElement.timeOutValue); | ||
} | ||
@@ -184,3 +186,3 @@ ) | ||
// Creating the DOM object for the toast | ||
var toastElement = this.buildToast(); | ||
this.toastElement = this.buildToast(); | ||
@@ -201,3 +203,3 @@ // Getting the root element to with the toast needs to be added | ||
// Adding the DOM element | ||
rootElement.insertBefore(toastElement, rootElement.firstChild); | ||
rootElement.insertBefore(this.toastElement, rootElement.firstChild); | ||
@@ -207,9 +209,11 @@ // Repositioning the toasts in case multiple toasts are present | ||
toastElement.timeOutValue = window.setTimeout( | ||
function() { | ||
// Remove the toast from DOM | ||
this.removeElement(toastElement); | ||
}.bind(this), | ||
this.options.duration | ||
); // Binding `this` for function invocation | ||
if (this.options.duration > 0) { | ||
this.toastElement.timeOutValue = window.setTimeout( | ||
function() { | ||
// Remove the toast from DOM | ||
this.removeElement(this.toastElement); | ||
}.bind(this), | ||
this.options.duration | ||
); // Binding `this` for function invocation | ||
} | ||
@@ -220,2 +224,9 @@ // Supporting function chaining | ||
hideToast: function() { | ||
if (this.toastElement.timeOutValue) { | ||
clearTimeout(this.toastElement.timeOutValue); | ||
} | ||
this.removeElement(this.toastElement); | ||
}, | ||
// Removing the element from the DOM | ||
@@ -222,0 +233,0 @@ removeElement: function(toastElement) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46901
479