#Toasts
Post popups over the page
You might use it in situations where: A query goes wrong, and you want to notify the user. The user has disconnected. The user has received a minor notification.
These situations don't necessarily require any action on the part of the user. Sometimes it's okay for the user to miss the notification altogether if they're not paying attention. But you want the information to be available for those who look. So you post a toast.
see the demo
##Primary Features
-
Extensively configurable. See API
-
No dependencies
-
As far as the author is aware, Toasts is the only library where toast position changes animate properly as their siblings start to expire. This was acheived through extensive use of fixed positioning. jQuery was not employed, though most toast libraries that use jQuery don't seem to have position animation either. The author really does not understand how people can bring themselves to use such unpolished UIs. Even soundcloud havn't gone to the trouble of animating position changes! The author realizes that the web platform makes this task difficult, but it's worth it, isn't it?! The visual sense is adapted for tracking moving objects! You can't just have things teleporting around the page!
##Example
(did you see the demo yet?)
var Toasts = require('toasts')
var toaster = new Toasts({gravity:[1,1] , defaults:{lifespan:Infinity , color:'blue' }})
toaster.post("watch out")
toaster.post("there's a man behind you")
toaster.post("admittedly quite far away", {color:'black'})
##API
new Toasts(config)
config: {
gravity:[number, number] = [1,-1],
fadeDuration:number = 200,
generationFunction: (msg:string, cfg, invokeDestruction:()=>void)=> {element:HTMLElement, ...},
cssWay: {elementClass, fadeInClass, fadeOutClass},
separation: number = 15,
defaults: {lifespan, color} = {lifespan:'suggested', color:'black'}
}
Creates a toaster.
Toasts.post(msg:string, cfg = Toasts.defaults):()=>void //posts a toast
Toasts. returns a lambda that can be be called to delete the toast.
###Specifying a custom generation function
generationFunction: (msg:string, cfg, invokeDestruction:()=>void)=> {
return {
element,
fadeIn,
fadeOut,
fadeDuration,
lifespan
}
}