Modal Window leanModal2 - Download Minimal Modal Window For Inline Content - leanModal2

Download Minimal Modal Window For Inline Content – leanModal2

Posted on

This time I will share jQuery Plugin and tutorial about Minimal Modal Window For Inline Content – leanModal2, hope it will help you in programming stack.

Modal Window leanModal2 - Download Minimal Modal Window For Inline Content - leanModal2
File Size: 15.9 KB
Views Total: 1374
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

leanModal2 is an upgrade version of the legacy jQuery leanModal plugin that helps you create minimal, easy-to-style modal windows from inline elements containing any content within the document.

More features:

  • FadeIn & FadeOut animations based on CSS3.
  • Closes the modal window by clicking the background overlay.
  • And/or by pressing the ESC key.
  • Always keep the modal be center on window resize.

How to use it:

1. Create the html content to display in the modal window.

1 <div id="modal-id" class="display-none example js-leanmodal-modal">
2   <h3>Hello World</h3>
3   <p>This is a modal window</p>
4   <a class="js-leanmodal-close">Close</a>
5 </div>

2. Hide the modal window on page load.

1 .display-none { display: none; }

3. Styleize the modal window whatever you like.

1 .example {
2   border-radius: 5px;
3   background-color: #fafafa;
4   padding: 2em;
5 }

4. Create a trigger element to toggle the modal window. Note that the value of ‘data-modal-id’ attribute must match the modal ID.

1 <button class="leanmodal-trigger"
2         data-modal-id="#modal-id">
3         Launch The Modal
4 </button>

5. Insert jQuery JavaScript library (slim build) and the jQuery leanModal2 plugin into the file.

2         integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
3         crossorigin="anonymous"></script>
4 <script src="jQuery.leanModal2.js"></script>

6. Enable the trigger element to toggle the modal window as needed.

1 $('.trigger-element').leanModal();

7. Possible configuration options with default values.

01 $('.trigger-element').leanModal({
02  
03   // use default styles
04   defaultStyles: true,
05  
06   // fade animation
07   fadeTime: 200,
08  
09   // opacity of background overlay
10   overlayOpacity: 0.7,
11  
12   // selector of close button
13   closeButton: '.js-leanmodal-close',
14  
15   // disable close on overlay click
16   disableCloseOnOverlayClick: false,
17  
18   // disable close by ESC key
19   disableCloseOnEscape: false,
20  
21   // center the modal
22   modalCenter: true
23    
24 });

This awesome jQuery plugin is developed by eustasy. For more Advanced Usages, please check the demo page or visit the official website.

source : jquery.net