Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vanillatoasts

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanillatoasts - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

2

package.json
{
"name": "vanillatoasts",
"version": "1.2.0",
"version": "1.3.0",
"description": "Agnostic Javascript Library for Website Notifications",

@@ -5,0 +5,0 @@ "main": "vanillatoasts.js",

@@ -8,11 +8,5 @@ ![VanillaToasts](http://puu.sh/iwxpd/eeee838c88.png)

##Installing
# Installing
Bower
```
$ bower install vanillatoasts
```
NPM
```
$ npm install vanillatoasts

@@ -25,10 +19,11 @@

```
<link rel="stylesheet" href="/bower_components/vanillatoasts/vanillatoasts.css">
<link rel="stylesheet" href="/path/to/vanillatoasts/vanillatoasts.css">
```
##Usage
# Usage
```
VanillaToasts.create({
// Create a toast
let toast = VanillaToasts.create({
title: 'Welcome to my site',

@@ -41,2 +36,9 @@ text: 'This toast will hide after 5000ms or when you click it',

});
// Hides the toast instantly
toast.hide()
// Timeout a toast at a later time
VanillaToasts.setTimeout(toast.id, 1000);
```

@@ -30,3 +30,11 @@ (function(root, factory) {

].join('\n'))
}
},
//function to manually set timeout after create
setTimeout: function() {
console.error([
'DOM has not finished loading.',
'\tInvoke create method when DOM\s readyState is complete'
].join('\n'))
},
toasts: {} //store toasts to modify later
};

@@ -99,7 +107,23 @@ var autoincrement = 0;

document.getElementById('vanillatoasts-container').removeChild(toast);
delete VanillaToasts.toasts[toast.id]; //remove toast from object
}
document.getElementById('vanillatoasts-container').appendChild(toast);
//add toast to object so its easily gettable by its id
VanillaToasts.toasts[toast.id] = toast;
return toast;
}
/*
custom function to manually initiate timeout of
the toast. Useful if toast is created as persistant
because we don't want it to start to timeout until
we tell it to
*/
VanillaToasts.setTimeout = function(toastid, val) {
if(VanillaToasts.toasts[toastid]){
setTimeout(VanillaToasts.toasts[toastid].hide, val);
}
}

@@ -106,0 +130,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc