Press "Enter" to skip to content

A Lightweight Alternative to the Vanilla JS Lightbox | yBox

yBox is a lightweight and feature-rich lightbox JavaScript library for images, videos, iframes, text, and any HTML content out of the box.

lightweight lightbox, lightbox javascript, lightbox gallery, jquery lightbox, basiclightbox, simple lightbox, bs responsive lightbox

How to make use of it:

1. Start by inserting the yBox’s JavaScript and CSS into the HTML doc.

<link rel="stylesheet" href="dist/css/yBox.min.css" />
<script src="dist/js/yBox.min.js"></script>

2. Initialize the yBox library and we’re able to go.

window.onload = function(){
  if(document.querySelector('.yBox')){
    var myYbox = new yBox();
     myYbox.init();
  };
}

3. Show a primary lightbox when needed.

myYbox.yBox('Lightbox Content Here');

4. Load content from any component throughout the doc.

<div style="display:none;">
  <div id="modalContent">
    Modal Content here
  </div>
</div>
<a class="yBox" href="#modalContent">Launch The Lightbox</a>

5. Open an iframe within the lightbox. Ideal for Youtube videos.

<a href="https://www.youtube.com/watch?v=1" class="yBox yBox_iframe">
  Open The Youtube Video
</a>

6. Load content through AJAX.

<a href="https://www.google.com" class="yBox yBox_ajax">
  Launch The Lightbox
</a>

7. Apply a further CSS class to the lightbox.

<a class="yBox" data-popup-class="customClass" href="#modalContent">Launch The Lightbox</a>

8. Create a gallery lightbox from a bunch of photos.

<a href="1.jpg" class="yBox" data-ybox-group="group1">
  // Add Image Here
</a>
<a href="2.jpg" class="yBox" data-ybox-group="group1">
  // Add Image Here
</a>
<a href="3.jpg" class="yBox" data-ybox-group="group1">
  // Add Image Here
</a>
...

9. Event handlers.

myYbox.onYboxOpen = function(){
  // Fired when yBox is opened
};

myYbox.onYboxClose = function(){
  // fired when yBox is closed
};

myYbox.onNextItemClick = function(){
  // fired when clicking next button
};

myYbox.onPrevItemClick = function(){
  // fired when clicking prev button
};

Full Featured Lightbox Alternative, yBox Plugin/Github

Lightbox-yBox-Demo


See Demo And Download

Official Website(Leshemiko): Click Here

This superior jQuery/javascript plugin is developed by Leshemiko. For extra advanced usage, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published.