Animated Notification Dialog In JavaScript – notification.js

Category: Javascript , Notification | September 3, 2022
Author:amaterasusan
Views Total:612 views
Official Page:Go to website
Last Update:September 3, 2022
License:MIT

Preview:

Animated Notification Dialog In JavaScript – notification.js

Description:

A lightweight and animated notification JavaScript library that helps you create toast-like flash messages and confirmation dialog popups.

How to use it:

1. Load the stylesheet notification.css and JavaScript notification.js in the HTML document.

<link href="./notification.css" rel="stylesheet" />
<script src="./notification.js"></script>

2. Create a new popup instance.

const popup = Notification({
      // options here
});

3. Create toast-style notifications.

popup.info({
  title: 'Message Title',
  message: 'Message Here',
});
popup.success({
  title: 'Message Title',
  message: 'Message Here',
});
popup.warning({
  title: 'Message Title',
  message: 'Message Here',
});
popup.error({
  title: 'Message Title',
  message: 'Message Here',
});
// OR
popup.showPopup({ 
  type: Type, 
  title: Title, 
  message: Message,
});

4. Create a confirmation dialog.

popup.dialog({
  title: 'Message Title',
  message: 'Message Here',
  callback: function(result){
    // do something
  }
});
// OR
popup.showPopup({ 
  type: 'dialog', 
  title: Title, 
  message: Message,
  callback: callback,
});

5. Customize the duration & position of the notification dialog.

const popup = Notification({
      
      // 'top-right', 'bottom-left'
      // 'top-left', 'center'
      position: 'bottom-right',
      // in milliseconds
      duration: 3000,
      
});

Changelog:

09/03/2022

  • Changed styles of pop-up notifications.
  • Added ability to assign duration equal to 0 (in this case popup notification will be displayed all the time)

You Might Be Interested In:


Leave a Reply