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?)
//we haven't specified a generation function though, so the notifications will have the default look. You probably don't want that. You're probably not so lazy or tasteless as to just use whatever is there instead of specifying your own look and structure. In this case you should probably take a look at the generation API below. toaster.post"watch out" toaster.post"there's a man behind you" toaster.post"admittedly quite far away",
API
new Toastsconfigconfig:
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: