Smooth Animated Lightbox Gallery In Pure JavaScript – MVT-Lightbox

Category: Gallery , Javascript , Modal & Popup | July 8, 2024
Views Total:9 views
Official Page:Go to website
Last Update:July 8, 2024


Smooth Animated Lightbox Gallery In Pure JavaScript – MVT-Lightbox


MVT-Lightbox is a pure JavaScript library for showcasing your images in a responsive, accessible gallery lightbox popup that uses CSS3 for smooth and fast animations.

See also:

How to use it:

Load the required style sheet in the header of the html page.

<link rel="stylesheet" href="mvt-lightbox.min.css">

Load the mvt-lightbox.min.js right before the closing body tag.

<script src="js/mvt-lightbox.min.js"></script>

Add a list of thumbnails together with the lightbox containing larger images to the webpage as follows:

<section data-lightbox="mvt-lightbox">
  <ul class="mvt-thumbs-list">
          <img src="1-thumb.jpg" alt="">
          <img src="2-thumb.jpg" alt="">
          <img src="3-thumb.jpg" alt="">
          <img src="4-thumb.jpg" alt="">
          <img src="5-thumb.jpg" alt="">
          <img src="6-thumb.jpg" alt="">
  <div class="mvt-lightbox-overlay no-display"></div>
  <div class="mvt-lightbox" data-show-id="">
      <div class="mvt-img-list">
          <img src="1.jpg" alt="">
          <img src="2.jpg" alt="">
          <img src="3.jpg" alt="">
          <img src="4.jpg" alt="">
          <img src="5.jpg" alt="">
          <img src="6.jpg" alt="">
      <div class="mvt-btn-close">
          <svg viewBox="0 0 45 45" xmlns="">
              <path d="M27.344,4.287 L23.531,0.474 L14,10.005 L4.469,0.474 L0.656,4.287 L10.187,13.818 L0.656,23.349 L4.469,27.162 L14,17.631 L23.531,27.162 L27.344,23.349 L17.813,13.818 L27.344,4.287 Z"></path>
      <div class="lightbox-nav-next">
          <svg viewBox="0 0 512 512" xmlns="">
              <path d="M181.683 512.5L96.35 427.203l170.632-170.67L96.352 85.868 181.68.5 437.65 256.534 181.682 512.5z" />
      <div class="lightbox-nav-prev">
          <svg viewBox="0 0 512 512" xmlns="">
              <path d="M85.683,512.5 L0.35,427.203 L170.982,256.533 L0.352,85.868 L85.68,0.5 L341.65,256.534 L85.682,512.5 L85.683,512.5 Z" transform="translate(171.000000, 256.500000) scale(-1, 1) translate(-171.000000, -256.500000) "/>

Initialize the gallery lightbox and done.

document.addEventListener('DOMContentLoaded', function() {
}, false);



  • JS Refactor


  • Make lightbox keyboard accessible.


  • Replace velocity fade animation with CSS animation


  • Update velocity lib, clean up unused files. Remove mixin for css prefixes. Update js file using es6 let and const.

You Might Be Interested In:

2 thoughts on “Smooth Animated Lightbox Gallery In Pure JavaScript – MVT-Lightbox

  1. setheaster

    Sorry if this is a stupid question, but for the life of me I cannot figure out where to put that last bit of code to initialize the lightbox?? Thanks

  2. Madhav Paudel

    If there are more images on the page and if I click the last image of the page, the popop of images is in the top. So we have to scroll to top to see the last image. How to fix this error?


Leave a Reply