Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <html>
  <head>
    <title>Martyn Lee Ball - Lightbox</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  </head>
  <body>
    <div id="main-wrap">
      <div class="container">
        <h1>Group 1</h1>
       <img src="https://mgreviewsblog.files.wordpress.com/2014/08/2011-suzuki-gsxr-750-1.jpg" alt="Image 1" class="responsive-img" data-lightbox-group="gsxr" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/08/2011-suzuki-gsxr-750-3.jpg" alt="Image 2" class="responsive-img" data-lightbox-group="gsxr" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/08/2011-suzuki-gsxr-750-4.jpg" alt="Image 3" class="responsive-img" data-lightbox-group="gsxr" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/08/2011-suzuki-gsxr-750-9.jpg" alt="Image 4" class="responsive-img" data-lightbox-group="gsxr" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/08/2011-suzuki-gsxr-750-2.jpg" alt="Image 5" class="responsive-img" data-lightbox-group="gsxr" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/08/2011-suzuki-gsxr-750-6.jpg?w=1024&h=620" alt="Image 6" class="responsive-img" data-lightbox-group="gsxr" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/08/2011-suzuki-gsxr-750-8.jpg" alt="Image 7" class="responsive-img" data-lightbox-group="gsxr" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/08/2011-suzuki-gsxr-750-7.jpg" alt="Image 8" class="responsive-img" data-lightbox-group="gsxr" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/08/2011-suzuki-gsxr-750-5.jpg" alt="Image 9" class="responsive-img" data-lightbox-group="gsxr" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/08/2011-suzuki-gsxr-750-10.jpg?w=1024&h=620" alt="Image 10" class="responsive-img" data-lightbox-group="gsxr" data-lightbox-name="Gallery">
        <h1>Group 2</h1>
       <img src="https://mgreviewsblog.files.wordpress.com/2014/11/2014-2015-seattle-motorcycle-show-51-copy.jpg" alt="Image 1" class="responsive-img" data-lightbox-group="ninja" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/11/2014-2015-seattle-motorcycle-show-52-copy.jpg" alt="Image 2" class="responsive-img" data-lightbox-group="ninja" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/11/2014-2015-seattle-motorcycle-show-53-copy.jpg" alt="Image 3" class="responsive-img" data-lightbox-group="ninja" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/11/2014-2015-seattle-motorcycle-show-54-copy.jpg" alt="Image 4" class="responsive-img" data-lightbox-group="ninja" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/11/2014-2015-seattle-motorcycle-show-55-copy.jpg" alt="Image 5" class="responsive-img" data-lightbox-group="ninja" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/11/2014-2015-seattle-motorcycle-show-56-copy.jpg" alt="Image 6" class="responsive-img" data-lightbox-group="ninja" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/11/2014-2015-seattle-motorcycle-show-57-copy.jpg" alt="Image 7" class="responsive-img" data-lightbox-group="ninja" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/11/2014-2015-seattle-motorcycle-show-58-copy.jpg" alt="Image 8" class="responsive-img" data-lightbox-group="ninja" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/11/2014-2015-seattle-motorcycle-show-59-copy.jpg" alt="Image 9" class="responsive-img" data-lightbox-group="ninja" data-lightbox-name="Gallery">
       <img src="https://mgreviewsblog.files.wordpress.com/2014/11/2014-2015-seattle-motorcycle-show-62-copy.jpg" alt="Image 10" class="responsive-img" data-lightbox-group="ninja" data-lightbox-name="Gallery">
    </div>
    </div>
  </body>
</html>
            
          
!
            
              body {
  font-family: 'Open Sans', sans-serif;
}
.responsive-img {
  max-width: 100%;
  max-height: 100%;
}
.container img {
  width: 10%;
}
.addedLightbox {
  border: transparent solid 2px;
  &.active {
    border: red solid 2px;
    @media (max-width: 739px) {
      display: inline-block;
    }
  }
}

@keyframes fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes fade-out {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes nextChange {
  100% { width: 100%; }
}
body.lightboxActive { overflow: hidden; }
#lightbox {
  .nextChange {
    position: absolute;
    top: 0;
    left: 0;
    width: 0%;
    height: 5px;
    background: #00b7ff;
    z-index: 999;
  }
  opacity: 1;
  & > *::selection {
    background: none;
  }
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: fade(#000, 85%);
  animation: fade-in forwards .5s ease-in-out;
  &.remove {
    animation: fade-out forwards .5s ease-in-out;
  }
  .lightboxSlider {
    &__counter {
      color: #fff;
      position: absolute;
      top: 20px;
      left: 20px;
      padding: 10px;
      @media (max-width: 739px) {
        top: 0;
        left: 0;
      }
    }
    &__header {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 10vh;
      display: flex;
      justify-content: center;
      z-index: 12;
      align-items: center;
      @media handheld, only screen and (orientation: landscape) and (max-width: 739px) {-20px
        height: 20vh;
      }

      background: linear-gradient(to bottom, rgba(0,0,0,1) 0%,rgba(0,0,0,0) 100%);
    }
    &__title {
      color: #fff;
      font-size: 22px;
      margin-left: auto;
      margin-right: auto;
      width: 100%;
      text-align: center;
      @media (max-width: 739px) {
        margin-top: 40px;
        font-size: 14px;
      }
      @media handheld, only screen and (orientation: landscape) and (max-width: 739px) {
        margin-top: 10px;
      }
    }
    &__tools {
      position: absolute;
      top: 20px;
      right: 20px;
      display: flex;
      @media (max-width: 739px) {
        top: 0;
        right: 0;
      }
      &--close, &--zoomin, &--zoomout, &--zoomreset,&--play, &--pause {
        cursor: pointer;
        transition: transform .2s ease-in-out;
        display: flex;
        align-content: center;
        justify-content: center;
        padding: 10px;
        @media (max-width: 739px) {
          padding: 8px;
        }
        &:before {
          color: #fff;
          font-family: 'FontAwesome';
          font-size: 20px;
          transition: all .3s ease-in-out;
          @media (max-width: 739px) {
            font-size: 20px;
          }
        }
        &.disabled {
          &:before {
            color: fade(#fff, 50%);
            cursor: not-allowed;
          }
          &:hover {
            transform: scale(1);
          }
        }
        &:hover {
          transform: scale(1.2);
        }
      }
      &--close:before { content: '\f00d'; }
      &--zoomin:before { content: '\f00e'; }
      &--zoomout:before { content: '\f010'; }
      &--zoomreset:before { content: '\f2d2'; }
      &--play:before { content: '\f01d'; }
      &--pause:before { content: '\f28c'; }
    }
    &__main {
      height: calc(~'100vh - 88px');
      display: flex;
      align-items: center;
      justify-content: space-between;
      @media (max-width: 739px) {
        height: calc(~'90vh - 50px');
        flex-direction: column;
      }
      @media handheld, only screen and (orientation: landscape) and (max-width: 739px) {
        height: calc(~'100vh - 50px');
        flex-direction: row;
        margin-top: 0;
      }
    }
    &__maincontrols, &__image {
      position: relative;
    }
    &__imagecontrols {
      position: absolute;
      top: 0;
      width: 50%;
      height: 100%;

      &--left { left: 0; }
      &--right { right: 0; }
    }
    &__maincontrols {
      float: left;
      height: 100%;
      width: 5%;
      justify-content: center;
      align-items: center;
      display: flex;
      font-size: 60px;
      @media (max-width: 739px) {
        height: 10%;
        width: 50%;
        order: 2;
        background: #000;
        &:before {
          color: #fff;
          font-size: 33px;
        }
      }
      @media handheld, only screen and (orientation: landscape) and (max-width: 739px) {
        order: inherit;
        width: 10%;
        z-index: 9;
        height: 100%;
      }
      &--left, &--right {
        @media (max-width: 739px) {
          position: fixed;
          bottom: 50px;
          z-index: 9;
        }
        &:before {
          font-family: 'FontAwesome';
          color: #515151;
          transition: all .3s ease-in-out;
        }
        &:hover:before {
          color: #fff;
        }
      }
      &--left {
        @media (max-width: 739px) { left: 0; }
        margin-left: 0;
        margin-right: auto;
        &:before { content: '\f104'; }
      }
      &--right {
        @media (max-width: 739px) { right: 0; }
        margin-right: 0;
        margin-left: auto;
        &:before { content: '\f105'; }
      }
    }
    &__image {
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform .3s ease-in-out;
      @media (max-width: 739px) {
        order: 1;
        justify-content: center;
        height: 100%;
      }
      @media handheld, only screen and (orientation: landscape) and (max-width: 739px)
      {
        margin-top: 0;
        margin-bottom: auto;
        width: 100%;
        order: inherit;
      }
      img::selection {
        background: none;
      }
    }
    &__bottom {
      background: #000;
      height: 88px;
      position: relative;
      z-index: 10;
      border-top: #252024 solid 1px;
      padding-left: calc(~'50% - 35.5px');
      @media (max-width: 739px) {
        height: 50px;
        position: fixed;
        bottom: 0;
        left: 0;
      }
      span {
        float: left;
        width: 71px;
        height: 71px;
        overflow: hidden;
        flex: 0 0 71px;
        margin: 8px;
        display: flex;
        justify-content: center;

        @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
          display: block;
          width: 100px;
          overflow: visible;
          flex: none;
        }

        @media (max-width: 739px) {
          width: 42px;
          height: 42px;
          margin: 4px;
          flex: 0 0 42px;
        }
        img {
          height: 100%;
          opacity: 0.6;
          transition: opacity .3s ease-in-out;
          @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
            height: auto;
            max-width: 100%;
            max-height: 100%;
          }
        }
        &.active img, &:hover img {
          opacity: 1;
        }
      }
      .thumbnails {
        transition: all .5s ease-in-out;
        display: flex;
      }
    }
    &__gallery {
      float: right;
      height: 87px;
      width: 87px;
      position: absolute;
      right: 0;
      bottom: 0;
      cursor: pointer;

      display: flex;
      align-content: center;
      justify-content: center;
      z-index: 99;
      background: #000;

      @media (max-width: 739px) {
        height: 49px;
        width: 49px;
        position: fixed;  
        &:before {
          font-size: 24px;
        }
      }

      &:before {
        content: '\f009';
        font-family: 'FontAwesome';
        color: #fff;
        align-self: center;
        font-size: 40px;
      }
    }
    &--hide-controls {
      .lightboxSlider {
        &__gallery, 
        &__maincontrols, 
        &__imagecontrols, 
        &__bottom {
          display: none;
        }
        &__image {
          margin-left: auto;
          margin-right: auto;
        }

        &__tools {
          &--play, &--pause {
            display: none;
          }
        }
      }
    }
  }
  &.hover-left .lightboxSlider__maincontrols--left:before { color: #fff; }
  &.hover-right .lightboxSlider__maincontrols--right:before { color: #fff; }
  &.gallery_active .lightboxSlider { opacity: 0; }

  .lightboxGallery {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 15;
    &__header {
      height: 10vh;
      width: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      color: #fff;
      @media (max-width: 739px) { height: 20vh; }
    }
    &__back {
      color: #fff;
      position: absolute;
      top: 20px;
      left: 20px;
      font-size: 20px;
      cursor: pointer; 
      @media (max-width: 739px) {
        top: 10px;
        left: 10px;
        font-size: 14px;
      }
      &:before {
        content: '\f104';
        font-family: 'FontAwesome';
        color: #fff;
        margin-right: 10px;
      }
    }
    &__close {
      position: absolute;
      top: 20px;
      right: 20px;
      cursor: pointer;
      transition: transform .2s ease-in-out;

      @media (max-width: 739px) {
        top: 10px;
        right: 10px;
      }

      display: flex;
      align-content: center;
      justify-content: center;

      &:before {
        content: '\f00d';
        color: #515151;
        font-family: 'FontAwesome';
        font-size: 20px;
        transition: all .3s ease-in-out;
        @media (max-width: 739px) {
          font-size: 14px;
          color: #fff;
        }
      }
      &:hover:before {
        color: #fff;
      }
    }
    &__title {
      color: #fff;
      font-size: 22px;  
      margin-left: auto;
      margin-right: auto;
    }
    &__main {
      width: 100vw;
      height: 90vh;
      text-align: center;
      @media (max-width: 739px) { 
        height: 80vh;
        overflow-x: hidden;
        overflow-y: scroll;
      }
      span {
        display: inline-block;
        opacity: .6;
        height: 210px;
        position: relative;
        width: 16%;
        margin: 1%;
        @media (max-width: 739px) {
          width: 31%;
        }
        &:hover{
          opacity: 1;
        }
        &.active {
          opacity: 1;
          &:before {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 0;
            border-top: 60px solid #1d8b10;
            border-left: 60px solid transparent;
            height: 0;
            @media (max-width: 739px) {
              border-top-width: 30px;
              border-left-width: 30px;
            }
          }
          &:after {
            content: '\f06e';
            font-family: 'FontAwesome';
            color: #fff;
            position: absolute;
            font-size: 22px;
            top: 5px;
            right: 5px;
            @media (max-width: 739px) {
              font-size: 12px;
              top: 2px;
              right: 2px;
            }
          }
        }
      }
    }
  }
}
body.ie9 {
  #lightbox {
    .lightboxSlider {
      &__main {
        display: block;
        width: 100%;
        height: 100%;
      }
      &__image {
        float: left;
        width: 90%;
        text-align: center;
        @media (max-width: 739px) {
          width: 100%;
          padding-top: 30%;
        }
      }
      &__tools {
        float: left;
        &--zoomin, &--zoomout, &--zoomreset {
          display: none;
        }
        @media (max-width: 739px) {
          right: 0;
          left: auto;
        }
      }
      &__header {
        background: fade(#000, 60%);
        height: 80px;
      }
      &__title {
        margin-top: 30px;
      }
      &__maincontrols {
        height: auto;
        width: 5%;
        display: flex;
        padding-top: calc(~'25% - 20px');
        box-sizing: border-box;
        text-align: center;
        @media (max-width: 739px) {
          padding-top: 0;
          width: 50%;
          font-size: 30px;
          bottom: 0;
        }
        &--left {
          float: left;
          margin-left: 0;
          margin-right: auto;
        }
        &--right {
          float: right;
          margin-right: 0;
          margin-left: auto;
        }
      }
      &__bottom {
        display: none;
      }
    }
  }
}
            
          
!
            
              
// Polyfill Functions //
(function() {
  if (typeof Object.assign != 'function') {
    Object.assign = function (target, varArgs) { // .length of function is 2
      'use strict';
      if (target == null) { // TypeError if undefined or null
        throw new TypeError('Cannot convert undefined or null to object');
      }

      var to = Object(target);

      for (var index = 1; index < arguments.length; index++) {
        var nextSource = arguments[index];

        if (nextSource != null) { // Skip over if undefined or null
          for (var nextKey in nextSource) {
            // Avoid bugs when hasOwnProperty is shadowed
            if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
              to[nextKey] = nextSource[nextKey];
            }
          }
        }
      }
      return to;
    };
  }
}());
(function() {
  if (!document.documentElement.dataset && (!Object.getOwnPropertyDescriptor(Element.prototype, 'dataset') || !Object.getOwnPropertyDescriptor(Element.prototype, 'dataset').get)) {
    var propDescriptor = {
      enumerable: true,
      get: function () {
        'use strict';
        var i,
          that = this,
          HTML5_DOMStringMap,
          attrVal, attrName, propName,
          attribute,
          attributes = this.attributes,
          attsLength = attributes.length,
          toUpperCase = function (n0) {
            return n0.charAt(1).toUpperCase();
          },
          getter = function () {
            return this;
          },
          setter = function (attrName, value) {
            return (typeof value !== 'undefined') ?
              this.setAttribute(attrName, value) :
              this.removeAttribute(attrName);
          };
        try { // Simulate DOMStringMap w/accessor support
          // Test setting accessor on normal object
          ({}).__defineGetter__('test', function () {});
          HTML5_DOMStringMap = {};
        } catch (e1) { // Use a DOM object for IE8
          HTML5_DOMStringMap = document.createElement('div');
        }
        for (i = 0; i < attsLength; i++) {
          attribute = attributes[i];
          // Fix: This test really should allow any XML Name without 
          //         colons (and non-uppercase for XHTML)
          if (attribute && attribute.name &&
            (/^data-\w[\w\-]*$/).test(attribute.name)) {
            attrVal = attribute.value;
            attrName = attribute.name;
            // Change to CamelCase
            propName = attrName.substr(5).replace(/-./g, toUpperCase);
            try {
              Object.defineProperty(HTML5_DOMStringMap, propName, {
                enumerable: this.enumerable,
                get: getter.bind(attrVal || ''),
                set: setter.bind(that, attrName)
              });
            } catch (e2) { // if accessors are not working
              HTML5_DOMStringMap[propName] = attrVal;
            }
          }
        }
        return HTML5_DOMStringMap;
      }
    };
    try {
      // FF enumerates over element's dataset, but not 
      //   Element.prototype.dataset; IE9 iterates over both
      Object.defineProperty(Element.prototype, 'dataset', propDescriptor);
    } catch (e) {
      propDescriptor.enumerable = false; // IE8 does not allow setting to true
      Object.defineProperty(Element.prototype, 'dataset', propDescriptor);
    }
  }
}());
(function() {
  if ("document" in self) {

  if (!("classList" in document.createElement("_")) 
    || document.createElementNS && !("classList" in document.createElementNS("http://www.w3.org/2000/svg","g"))) {

  (function (view) {
  "use strict";

  if (!('Element' in view)) return;

  var
      classListProp = "classList"
    , protoProp = "prototype"
    , elemCtrProto = view.Element[protoProp]
    , objCtr = Object
    , strTrim = String[protoProp].trim || function () {
      return this.replace(/^\s+|\s+$/g, "");
    }
    , arrIndexOf = Array[protoProp].indexOf || function (item) {
      var
          i = 0
        , len = this.length
      ;
      for (; i < len; i++) {
        if (i in this && this[i] === item) {
          return i;
        }
      }
      return -1;
    }
    // Vendors: please allow content code to instantiate DOMExceptions
    , DOMEx = function (type, message) {
      this.name = type;
      this.code = DOMException[type];
      this.message = message;
    }
    , checkTokenAndGetIndex = function (classList, token) {
      if (token === "") {
        throw new DOMEx(
            "SYNTAX_ERR"
          , "An invalid or illegal string was specified"
        );
      }
      if (/\s/.test(token)) {
        throw new DOMEx(
            "INVALID_CHARACTER_ERR"
          , "String contains an invalid character"
        );
      }
      return arrIndexOf.call(classList, token);
    }
    , ClassList = function (elem) {
      var
          trimmedClasses = strTrim.call(elem.getAttribute("class") || "")
        , classes = trimmedClasses ? trimmedClasses.split(/\s+/) : []
        , i = 0
        , len = classes.length
      ;
      for (; i < len; i++) {
        this.push(classes[i]);
      }
      this._updateClassName = function () {
        elem.setAttribute("class", this.toString());
      };
    }
    , classListProto = ClassList[protoProp] = []
    , classListGetter = function () {
      return new ClassList(this);
    }
  ;
  // Most DOMException implementations don't allow calling DOMException's toString()
  // on non-DOMExceptions. Error's toString() is sufficient here.
  DOMEx[protoProp] = Error[protoProp];
  classListProto.item = function (i) {
    return this[i] || null;
  };
  classListProto.contains = function (token) {
    token += "";
    return checkTokenAndGetIndex(this, token) !== -1;
  };
  classListProto.add = function () {
    var
        tokens = arguments
      , i = 0
      , l = tokens.length
      , token
      , updated = false
    ;
    do {
      token = tokens[i] + "";
      if (checkTokenAndGetIndex(this, token) === -1) {
        this.push(token);
        updated = true;
      }
    }
    while (++i < l);

    if (updated) {
      this._updateClassName();
    }
  };
  classListProto.remove = function () {
    var
        tokens = arguments
      , i = 0
      , l = tokens.length
      , token
      , updated = false
      , index
    ;
    do {
      token = tokens[i] + "";
      index = checkTokenAndGetIndex(this, token);
      while (index !== -1) {
        this.splice(index, 1);
        updated = true;
        index = checkTokenAndGetIndex(this, token);
      }
    }
    while (++i < l);

    if (updated) {
      this._updateClassName();
    }
  };
  classListProto.toggle = function (token, force) {
    token += "";

    var
        result = this.contains(token)
      , method = result ?
        force !== true && "remove"
      :
        force !== false && "add"
    ;

    if (method) {
      this[method](token);
    }

    if (force === true || force === false) {
      return force;
    } else {
      return !result;
    }
  };
  classListProto.toString = function () {
    return this.join(" ");
  };

  if (objCtr.defineProperty) {
    var classListPropDesc = {
        get: classListGetter
      , enumerable: true
      , configurable: true
    };
    try {
      objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
    } catch (ex) { // IE 8 doesn't support enumerable:true
      // adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36
      // modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected
      if (ex.number === undefined || ex.number === -0x7FF5EC54) {
        classListPropDesc.enumerable = false;
        objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
      }
    }
  } else if (objCtr[protoProp].__defineGetter__) {
    elemCtrProto.__defineGetter__(classListProp, classListGetter);
  }

  }(self));

  }

  // There is full or partial native classList support, so just check if we need
  // to normalize the add/remove and toggle APIs.

  (function () {
    "use strict";

    var testElement = document.createElement("_");

    testElement.classList.add("c1", "c2");

    // Polyfill for IE 10/11 and Firefox <26, where classList.add and
    // classList.remove exist but support only one argument at a time.
    if (!testElement.classList.contains("c2")) {
      var createMethod = function(method) {
        var original = DOMTokenList.prototype[method];

        DOMTokenList.prototype[method] = function(token) {
          var i, len = arguments.length;

          for (i = 0; i < len; i++) {
            token = arguments[i];
            original.call(this, token);
          }
        };
      };
      createMethod('add');
      createMethod('remove');
    }

    testElement.classList.toggle("c3", false);

    // Polyfill for IE 10 and Firefox <24, where classList.toggle does not
    // support the second argument.
    if (testElement.classList.contains("c3")) {
      var _toggle = DOMTokenList.prototype.toggle;

      DOMTokenList.prototype.toggle = function(token, force) {
        if (1 in arguments && !this.contains(token) === !force) {
          return force;
        } else {
          return _toggle.call(this, token);
        }
      };

    }

    testElement = null;
  }());

  }
}());
// END Poly Functions //

// Custom Prototypes
String.prototype.objectType = function () {
  var t = null,
    type;
  switch (this.charAt(0)) {
    case '#':
      type = 'id';
      t = document.getElementById(this.replace('#', ''));
      break;
    case '.':
      type = 'class';
      t = document.getElementsByClassName(this.replace('.', ''))[0];
      break;
    default:
      type = 'class';
      t = document.getElementsByClassName(this.replace('.', ''))[0];
      break;
  }
  return t;
};
HTMLElement.prototype.offset = function () {
  var _ = this;

  var left = 0,
    right = 0,
    top = 0,
    bottom = 0;

  do {
    if (!isNaN(_.offsetLeft)) {
      left += _.offsetLeft;
    }
  } while (_ = _.offsetParent);
  _ = this;

  do {
    if (!isNaN(_.offsetTop)) {
      top += _.offsetTop;
    }
  } while (_ = _.offsetParent);
  _ = this;

  do {
    if (!isNaN(_.offsetRight)) {
      right += _.offsetRight;
    }
  } while (_ = _.offsetParent);
  _ = this;

  do {
    if (!isNaN(_.offsetBottom)) {
      bottom += _.offsetBottom;
    }
  } while (_ = _.offsetParent);
  _ = this;

  return {
    left: left,
    top: top,
    right: right,
    bottom: bottom
  };
};
String.prototype.generateHTMLfromJSON = function () {
  var handleAttribute = function (element, attribute, value) {
    if (value instanceof HTMLElement) {
      return element.appendChild(value);
    }
    switch (attribute) {
      case 'class':
      case 'src':
      case 'id':
      case 'data-click':
      case 'data-hover':
      case 'data-name':
        element.setAttribute(attribute, value);
        return;
      case 'content':
        element.innerHTML = value;
        return;
      case 'watch':
      case 'unwatch':
        return;
      default:
        console.log(element.tagName, attribute, value);
    }
  };
  var htmlReviver = function (key, value) {
    // parse as element
    if (isNaN(key) && typeof value === 'object') {
      var element = document.createElement(key);
      var subValue;

      for (var attribute in value) {
        handleAttribute(element, attribute, value[attribute]);
      }

      return element;
    } else if (!isNaN(key)) {
      return value[Object.keys(value)[0]];
    } else {
      return value;
    }
  };
  var object;

  try {
    object = JSON.parse(this, htmlReviver);
  } catch (e) {
    return [false, e];
  }
  return [true, object];
}
function whichAnimationEvent() {
  var t,
    el = document.createElement("fakeelement");

  var animations = {
    "animation": "animationend",
    "OAnimation": "oAnimationEnd",
    "MozAnimation": "animationend",
    "WebkitAnimation": "webkitAnimationEnd"
  }

  for (t in animations) {
    if (el.style[t] !== undefined) {
      return animations[t];
    }
  }
}
// END Custom Prototypes

// Plugin Start
class LightBox {

  constructor(node) {
    const _ = this;

    Object.assign(this, {
      node: node,
      label: node.dataset.lightboxName,
      group: node.dataset.lightboxGroup,
      enabled: true,
      id: 'lightbox',

      activeClass: 'lightboxActive',
      appendTo: '#main-wrap',
      debug: false,

      // Visual settings
      showTitle: true,
      showMax: true,
      showThumbs: true,

      // Store variables
      count: 0, // Count images
      active: false, // Is lightbox active?

      autoplay: { 
        delay: 3000,
        timer: null,
        enabled: true,
        initiallyDisabled: true
      },

      current: null, // Current image index
      last: 0, // Last image index

      zoom: {
        state: 0,
        levels: {
          0: 1,
          1: 1.5,
          2: 2,
          3: 2.5
        },
        enabled: null
      },

      // Errors occured?
      error: false,

      lightboxHTML: '{ "div": { "id": "{name}", "0": { "div": { "class": "lightboxSlider", "data-name": "container", "0": { "div": { "class": "{name}Slider__header", "data-name": "header", "data-click": "EventClose", "0": { "div": { "class": "{name}Slider__counter", "data-name": "counter" } }, "1": { "div": { "class": "{name}Slider__title", "data-name": "title" } }, "2": { "div": { "class": "{name}Slider__tools", "0": { "div": { "class": "{name}Slider__tools--play", "data-click": "EventPlay", "data-name": "play" } }, "1": { "div": { "class": "{name}Slider__tools--pause disabled", "data-click": "EventPause", "data-name": "pause" } }, "2": { "div": { "class": "{name}Slider__tools--zoomin", "data-click": "EventZoomIn", "data-name": "zoomin" } }, "3": { "div": { "class": "{name}Slider__tools--zoomout disabled", "data-click": "EventZoomOut", "data-name": "zoomout" } }, "4": { "div": { "class": "{name}Slider__tools--zoomreset", "data-click": "EventZoomReset", "data-name": "zoomreset" } }, "5": { "div": { "class": "{name}Slider__tools--close", "data-click": "EventClose", "data-name": "close" } } } } } }, "1": { "div": { "class": "{name}Slider__main", "data-click": "EventClose", "data-name": "main", "0": { "div": { "class": "{name}Slider__maincontrols {name}Slider__maincontrols--left", "data-click": "EventLeft", "data-name": "left" } }, "1": { "div": { "class": "{name}Slider__image", "data-name": "imageContainer", "0": { "div": { "class": "{name}Slider__imagecontrols {name}Slider__imagecontrols--left", "data-click": "EventLeft", "data-hover": "EventClass(#{name}, toggle: hover-left)", "data-name": "imageLeft" } }, "1": { "div": { "class": "{name}Slider__imagecontrols {name}Slider__imagecontrols--right", "data-click": "EventRight", "data-hover": "EventClass(#{name}, toggle: hover-right)", "data-name": "imageRight" } }, "2": { "img": { "src": "", "class": "responsive-img image", "data-name": "image" } } } }, "2": { "div": { "class": "{name}Slider__maincontrols {name}Slider__maincontrols--right", "data-click": "EventRight", "data-name": "right" } } } }, "2": { "div": { "class": "{name}Slider__bottom", "data-name": "bottom", "0": { "div": { "class": "{name}Slider__gallery", "data-click": "EventGallery" } } } } } } } }',

      thumbnailsHTML: '{ "div": { "class": "{name}Gallery", "data-name": "container", "0": { "div": { "class": "{name}Gallery__header", "data-name": "header", "0": { "div": { "class": "{name}Gallery__back", "data-name": "back", "content": "< Back" } }, "1": { "div": { "class": "{name}Gallery__title", "data-name": "title" } }, "2": { "div": { "class": "{name}Gallery__close", "data-click": "EventClose", "data-name": "close" } } } }, "1": { "div": { "class": "{name}Gallery__main", "data-click": "EventClose", "data-name": "main" } } } }',

      galleryHTML: '{ "div": { "class": "{name}Gallery", "data-name": "container", "0": { "div": { "class": "{name}Gallery__header", "data-name": "header", "data-click": "EventClose", "0": { "div": { "class": "{name}Gallery__back", "data-name": "back", "data-click": "EventGalleryClose", "content": "Back" } }, "1": { "div": { "class": "{name}Gallery__title", "data-name": "title", "content": "{group}" } }, "2": { "div": { "class": "{name}Gallery__close", "data-click": "EventClose", "data-name": "close" } } } }, "1": { "div": { "class": "{name}Gallery__main", "data-click": "EventClose", "data-name": "main" } } } }',
    });

    // We will use the group value to only get the images within this instance of the lightbox
    _.images = document.querySelectorAll('[data-lightbox-group=' + _.group + ']');

    // Replace bracelets
    _.lightboxHTML = this.lightboxHTML.replace(/\{(name)}/g, _.id);
    _.thumbnailsHTML = this.thumbnailsHTML.replace(/\{(name)}/g, _.id);
    _.galleryHTML = this.galleryHTML.replace(/\{(name)}/g, _.id);
    _.galleryHTML = this.galleryHTML.replace(/\{(group)}/g, _.label);

    // Lets start to setup the lightbox, only continue if no fatal errors occured

    if (!this.error) this.initEvents.call(this); // Setup object with lightbox update functions
    if (!this.error) this.initHTML.call(this); // Generate the HTML for the lightbox

    (function() {
      var compile = [];

      for(var i = 0; i < _.images.length; i++) {
        _.images[i].classList.add('addedLightbox'); // Add some reference to the image that it has been added, styling?

        var tmp = {
          index: _.count, // We want a unique index for each image
          object: _.images[i], // Store a reference to the image
          src: function () { // Establish if a different image should be used when viewed in the lightbox
            if (_.images[i].hasAttribute('data-lightbox-large')) return _.images[i].getAttribute('data-lightbox-large');
            return _.images[i].src;
          }(),
          active: { val: 0 },
          alt: function () {
            if (_.images[i].hasAttribute('alt')) return _.images[i].getAttribute('alt');
            return '';
          }()
        }
        compile.push(tmp);
        _.count++; // Increase max number for each image
      }
      _.images = compile;
    }());

    if (!this.error) this.initThumbnails.call(this, _.images);
    if (!this.error) this.openLightbox.call(this, _.images);

    if (!this.error) this.initKeyboard.call(this); // Assign events to keyboard events
    if (!this.error) this.initTouch.call(this); // Assign events to touch screen events

    // Add initial click events
    var addClickEvent = function(index) {
      var image = _.images[index];
      (image.object).addEventListener('click', function(event) {
        event.stopPropagation();
        _.openLightbox.call(_, image.index);
      });
    }
    for (var i = 0; i < _.images.length; i++) {
      addClickEvent(i);
    }

    /**
     *  Public Methods
     */
    _.public = function () {
      var a = arguments[0],
        b = arguments[1];
      switch (a) {
        // Actions
        case 'left':
          _.events.EventLeft();
          break;
        case 'right':
          _.events.EventRight();
          break;
        case 'slide':
          _.events.EventSlide((b - 1));
          break;
        case 'close':
          _.events.EventClose();
          break;
        case 'pause':
          _.events.EventPause();
          break;

          // Return Values
        case 'get':
          return _.events.ReturnVal(b);
      }
    }
  }

  /**
   * Initiate lightbox for all groups found.
   */
  static init(node) {
    return new this(node);
  }
  static initAll(node) {
    var _ = this,
      instances = [];

    window.addEventListener('load', function () {
      var groups = document.querySelectorAll('[data-lightbox-group]');
      var current = [];
      var handleGroup = function (e) {
        instances.push(_.init(e)); // Setup new instance of this class for each group
      };

      // Establish unique group names and create new instances
      for (var i = 0; i < groups.length; i++) {
        var dataset = groups[i].dataset;
        if (current.indexOf(dataset.lightboxGroup) === -1) {
          current.push(dataset.lightboxGroup);
          handleGroup(groups[i]);
        }
      }
    });

    return instances;
  }

  addClickEvents(list /* list = { index, object, src, active } */ ) {
    const _ = this;

    // Assign click events for objects within the list
    var addClickEvent = function(index) {
      var image = list[index];
      (image.object).addEventListener('click', function (event) {
         event.stopPropagation();
        _.events.EventSlide.call(_, image.index);

      });
    }
    for (var i = 0; i < list.length; i++) {
      addClickEvent(i);
    }
  }

  /**
   *  Handle plugin for each group
   */
  initEvents() {
    var _ = this;

    _.events = {
      EventRight: function (evt) {
        if (!_.galleryActive) {
          var index = 0;
          if (evt) evt.stopPropagation();

          index = _.current + 1;
          if (_.current === (_.count - 1)) index = 0;

          _.changeImage.call(_, index); // Update lightbox

        }
      },
      EventLeft: function (evt) {
        if (!_.galleryActive) {
          var index = _.count;
          if (evt) evt.stopPropagation();

          // Previous image
          index = _.current - 1;
          if (_.current <= 0) index = (_.count - 1);

          _.changeImage.call(_, index); // Update lightbox
        }
      },
      EventClose: function (evt) {
        if (evt) evt.stopPropagation();

        _.openLightbox.call(_, null);

        // Make sure all active classes are removed
        for (var i = 0; i < _.images.length; i++) {
          _.images[i].active.val = 0;
        }
      },
      EventSlide: function (number) {
        if (_.images[number] !== undefined) {
          _.changeImage(number);

        } else {
          // No such image...
        }
      },
      EventClass: function (evt) {
        try {
          var arg = (evt.target.dataset.hover).replace(/ /g, ''),
            args = (arg.match(/[^(]*/g).filter(Boolean))[1].match(/(?:([^,()]+)?)+/g).filter(Boolean),
            target = args[0].objectType(),
            action = args[1].match(/^(.*):(.*)/).filter(Boolean);

          switch (action[1]) {
            case 'add':
              // Add class
              target.classList.add(action[2]);
              break;
            case 'remove':
              // Remove class
              target.classList.remove(action[2]);
              break;
            case 'toggle':
              target.classList.add(action[2]);
              evt.target.addEventListener('mouseout', function () {
                target.classList.remove(action[2]);
              });
              break;
            default:
              // action doesn't exist, log error
              break;
          }
        } catch (e) {
          // error
        }
      },
      ReturnVal: function (e) {
        var val;
        switch (e) {
          case 'count':
            val = _.count;
            break;
          case 'active':
            val = _.active;
            break;
          case 'current':
            val = _.current;
            break;
          case 'last':
            val = _.last;
            break;
          case 'images':
            val = _.images;
            break;
          case 'html':
            val = _.lightbox;
            break;
          default:
            val = _;
            break;
        }
        return val;
      },
      EventGallery: function () {
        _.galleryActive = true;
        if (_.autoplay.current !== undefined) _.autoplay.current.pause();
        _.gallery = _.HTMLfromJSON(_.galleryHTML);

        // Should duplicate the image reference, but keep reference to the active state
        var newList = [];
        var createImage = function (image, i) {

          // Create new instances of the images
          var img = document.createElement('img');
          img.src = image.object.src;
          img.classList.add('responsive-img');
          img.alt = image.alt;

          var span = document.createElement('span');
          span.appendChild(img);

          if (i === _.current) img.parentNode.classList.add('active');

          var newImage = {
            object: img,
            index: i,
            src: image.src,
            active: image.active, // Use reference to old list
            alt: image.alt
          };
          newList.push(newImage);

          newImage.object.addEventListener('click', function (evt) {

            evt.stopPropagation();
            _.changeImage.call(_, newImage.index);
            _.galleryActive = false;
            (_.gallery.object).parentNode.removeChild(_.gallery.object);

            if (_.autoplay.current !== undefined) _.autoplay.current.resume();

          });

          // Add each image to the gallery DOM
          _.gallery.main.appendChild(span);
        }

        for (var i = 0; i < _.images.length; i++) {
          createImage(_.images[i], i);
        }

        // Add the gallery to the DOM
        _.lightbox.object.appendChild(_.gallery.object);

      },
      EventGalleryClose: function (evt) {
        evt.stopPropagation();
        (_.gallery.object).parentNode.removeChild(_.gallery.object);
        _.galleryActive = false;
      },
      EventZoomIn: function(evt) {
        if (evt) evt.stopPropagation();
        _.manageZoom(1);
      },
      EventZoomOut: function(evt) {
        if (evt) evt.stopPropagation();
        _.manageZoom(0);
      },
      EventZoomReset: function(evt) {
        if (evt) evt.stopPropagation();
        _.manageZoom(null);
      },
      EventPause: function(evt) {
        if (evt) evt.stopPropagation();
        _.autoplay.current.master(true);
        _.autoplay.current.pause();
      },
      EventPlay: function(evt) {
        if (evt) evt.stopPropagation();
        _.autoplay.current.master(false);
        _.autoplay.current.resume();
      }
    };
  }
  changeImage(index) {
    const _ = this;

    _.lightbox.counter.innerHTML = (index + 1) + '/' + _.images.length;
    _.lightbox.image.src = _.images[index].src;
    _.lightbox.image.alt = _.images[index].alt;
    _.lightbox.title.innerHTML = _.images[index].alt;

    _.last = (_.current === null) ? index : _.current;
    _.current = index;

    _.images[index].active.val = 1;
    _.images[_.last].active.val = 0;

    // Move thumbnails
    if (_.showThumbs) _.updateThumbnailPadding(index);

    // Add/Remove active classes
    _.activeClasses(index);

    // Reset the zoom state if image is changed
    _.manageZoom(null);
  }
  manageZoom(zoom) {
    const _ = this;

    switch(zoom) {
      case 1:
      // Zoom in
      if (_.zoom.levels[(_.zoom.state + 1)] !== undefined) {
        _.zoom.state = _.zoom.state + 1;
        _.lightbox.imageContainer.style.transform = "scale(" + _.zoom.levels[_.zoom.state] + ")";
      }
      break;
      case 0:
      // Zoom out
      if (_.zoom.levels[(_.zoom.state - 1)] !== undefined) {
        _.zoom.state = _.zoom.state - 1;
        _.lightbox.imageContainer.style.transform = "scale(" + _.zoom.levels[_.zoom.state] + ")";
      }
      break;
      case null:
      // Reset
        _.zoom.state = 0; _.zoom.enabled = null;
        _.lightbox.imageContainer.style.transform = "scale(1)";
        _.lightbox.zoomin.classList.remove('disabled');
        _.lightbox.zoomout.classList.add('disabled');
      break;
    }

    if (_.zoom.levels[(_.zoom.state + 1)] === undefined) {
      _.lightbox.zoomin.classList.add('disabled');
    } else {
      _.lightbox.zoomin.classList.remove('disabled');
    }

    if (_.zoom.levels[(_.zoom.state - 1)] === undefined) {
      _.lightbox.zoomout.classList.add('disabled');
      if (_.autoplay.current !== undefined) _.autoplay.current.resume();
    } else {
      _.lightbox.zoomout.classList.remove('disabled');
      if (_.autoplay.current !== undefined) _.autoplay.current.pause();
    }

  }
  activeClasses(index) {
    const _ = this;

    if (index === null) {
      _.images[_.current].object.classList.remove('active');
      _.imagesThumbnails[_.current].object.parentNode.classList.remove('active');

      return;
    }

    _.images[_.last].object.classList.remove('active');
    _.images[index].object.classList.add('active');

    // Add class to the span
    _.imagesThumbnails[_.last].object.parentNode.classList.remove('active');
    _.imagesThumbnails[index].object.parentNode.classList.add('active');
  }
  HTMLfromJSON(html) {
    var _ = this,
      result;

    // Filter the event name, this is in the data attribute value
    var eventName = function (e) {
      return e.match(/[^(]*/);
    };

    try {
      // Try and generate the HTML from the JSON
      result = html.generateHTMLfromJSON();
    } catch (e) {
      console.log('Lightbox Error (Generating HTML): ' + e);
    }

    // Check that the HTML was generated
    if (result[0]) {

      // Assigned mouse events to the HTML based on data attributes, 
      // this will assign the lightbox events functions.
      Array.prototype.forEach.call(result[1].querySelectorAll('[data-hover]'), function (e) {
        e.addEventListener('mouseover', function (event) {
          _.events[eventName(e.dataset.hover)](event);
        });
      });
      Array.prototype.forEach.call(result[1].querySelectorAll('[data-click]'), function (e) {
        e.addEventListener('click', function (event) {
          _.events[eventName(e.dataset.click)](event);
        });
      });

      // Store a reference to key elements with the HTML and
      // store the main HTML object, allow access to this references to
      // extended classes for updates and bolt-ons. 
      var object = {};
      object['object'] = result[1];
      Array.prototype.forEach.call(result[1].querySelectorAll('[data-name]'), function (e) {
        object[e.dataset.name] = e;
      });

    } else {
      _.error = true; // HTML didn't generate
      console.log('error generating html: ' + result[1]);
    }

    // Return the HTML
    return object;
  }
  initHTML() {
    var _ = this;

    // Use JSON to generate the HTML, this allows the HTML structure to be changes
    _.lightbox = _.HTMLfromJSON(_.lightboxHTML);

    // If there is only 1 image add a class, some HTMLElement's may need to be hidden.
    if (_.images.length <= 1) {
      _.lightbox.container.classList.add(_.id + 'Slider--hide-controls');
    }
  }
  initThumbnails(list /* list = { index, object, src, active } */ ) {
    const _ = this;

    _.thumbnails = _.HTMLfromJSON(_.thumbnailsHTML); // Generate the HTML

    // Create a div to wrap the images in
    var wrapper = document.createElement('div');
    wrapper.classList.add('thumbnails');

    var newList = [];
    _.imagesThumbnails = [];

    for (var i = 0; i < _.images.length; i++) {
      var img = document.createElement('img');
      img.src = _.images[i].object.src;
      img.alt = _.images[i].alt;

      newList.push({
        object: img,
        index: i,
        src: _.images[i].src,
        alt: _.images[i].alt,
        active: _.images[i].active
      });

      var container = document.createElement('span');
      container.appendChild(newList[i].object);

      // Keep a reference to the thumbnails
      _.imagesThumbnails.push(newList[i]);

      // Append image to wrapper
      wrapper.appendChild(container);
    }

    _.addClickEvents(_.imagesThumbnails);
    _.lightbox.bottom.appendChild(wrapper);
    _.lightbox.thumbnailWrapper = wrapper;

  }
  openLightbox(index) {
    const _ = this;

    // If null is passed then close the lightbox
    if (index === null) {

      const transitionEvent = whichAnimationEvent();

      if (transitionEvent === undefined) {
        removeLightbox();
      }

      _.lightbox.object.classList.add("remove");
      _.lightbox.object.addEventListener(transitionEvent, removeLightbox);

      function removeLightbox(event) {
        if (transitionEvent !== undefined) {
          _.lightbox.object.removeEventListener(transitionEvent, removeLightbox);
        }
        _.lightbox.object.classList.remove("remove");
        if (_.lightbox.object) _.lightbox.object.parentNode.removeChild(_.lightbox.object);

        document.body.classList.remove(_.activeClass);

        _.activeClasses(null);
        _.manageZoom(null);

        _.active = false;
        _.current = null;

        if (_.autoplay.current !== undefined) {
          _.autoplay.current.stop();
          _.autoplay.current.master(true);
        }
      }

    } else {

      if (_.images[index] !== undefined) {

        _.last = (_.current === null) ? index : _.current;
        _.current = index;
        _.active = true;

        // Append the HTML if it doesn't yet exist
        if (('#lightbox').objectType() === null) {

          (_.appendTo).objectType().insertBefore(_.lightbox.object, ((_.appendTo).objectType()).firstChild);
          document.body.classList.add(_.activeClass);
          if (navigator.appVersion.indexOf("MSIE 9") > -1) document.body.classList.add('ie9');
          
          // Change the active image values
          _.images[_.last].active.val = 0;
          _.images[index].active.val = 1;

          if (_.autoplay.enabled && _.images.length > 1) _.initAutoplay.call(_);
        }

        _.events.EventSlide(index);
        
      } else {
        // Image doesn't exist
      }
    }
  }
  initAutoplay() {

    var _ = this, delayElm, newone;
    
    if (document.getElementById('nextChange')) {
      delayElm = document.getElementById('nextChange');
    } else {
      delayElm = document.createElement('div'), newone;
      delayElm.classList.add('nextChange');
      delayElm.id = 'nextChange';
      delayElm.style.animation = 'nextChange forwards ' + (_.autoplay.delay / 1000) + 's ease-in-out';
      delayElm.style.animationPlayState = 'paused';
      _.lightbox.container.insertBefore(delayElm, _.lightbox.container.firstChild);
    }

    _.autoplay.timer = function(callback, delay) {
      var timerId, start, remaining = delay, 
          paused = true, master = _.autoplay.initiallyDisabled;

      this.master = function(val) {
        master = val;
      }

      this.pause = function() {
        if (!paused) {
          window.clearTimeout(timerId);
          remaining -= new Date() - start;
          paused = true;

          this.togglePauseState();
        }
      };

      this.resume = function() {
        if (paused && !master) {
          start = new Date();
          timerId = window.setTimeout(callback, remaining);
          paused = false;

          this.togglePlayState();
        } else {
          this.togglePauseState();
        }
      };

      this.stop = function() {
        window.clearTimeout(timerId);
      };

      this.reset = function() {
        if (!paused) {
          window.clearTimeout(timerId);
          start = new Date(), remaining = delay;
          timerId = window.setTimeout(callback, delay);

          newone = delayElm.cloneNode(true);
          delayElm.parentNode.replaceChild(newone, delayElm);
          delayElm = newone;

          this.togglePlayState();
        }
      }

      this.togglePauseState = function() {
        _.lightbox.pause.classList.add('disabled');
        _.lightbox.play.classList.remove('disabled');
        delayElm.style.animationPlayState = 'paused';
        delayElm.style.WebkitAnimationPlayState = 'paused';
      };
      this.togglePlayState = function() {
        _.lightbox.pause.classList.remove('disabled');
        _.lightbox.play.classList.add('disabled');
        delayElm.style.animationPlayState = 'running';
        delayElm.style.WebkitAnimationPlayState = 'running';
      };

      this.resume();
    };


    var timer = new _.autoplay.timer(function() {
      if (_.active) {
        _.events.EventRight();
        timer.reset();
      }
    }, _.autoplay.delay);
    _.autoplay.current = timer;

  }
  initKeyboard() {
    var _ = this;

    document.addEventListener('keydown', function (e) {
      if (_.active) {
        e = e || window.event;
        if (e.keyCode === 37 || e.keyCode === 39 || e.keyCode === 27) {
          switch (e.keyCode) {
            case 39:
              _.events.EventRight(); // Right
              break;
            case 37:
              _.events.EventLeft(); // Left
              break;
            case 27:
              _.events.EventClose(); // Close
              break;
          }
        }
      }
    });
  }
  initTouch() {
    var _ = this;

    var xDown = null,
      yDown = null;

    document.addEventListener('touchstart', function (evt) {
      xDown = evt.touches[0].clientX;
      yDown = evt.touches[0].clientY;
    }, false);

    document.addEventListener('touchmove', function (evt) {
      if (_.current !== null) {
        if (!xDown || !yDown) {
          return;
        }

        var xUp = evt.touches[0].clientX;
        var yUp = evt.touches[0].clientY;

        var xDiff = xDown - xUp;
        var yDiff = yDown - yUp;

        if (Math.abs(xDiff) > Math.abs(yDiff)) {
          if (xDiff > 0) {
            _.events.EventRight(); // Right
          } else {
            _.events.EventLeft(); // Left
          }
        }

        /* reset values */
        xDown = null;
        yDown = null;
      }
    });
  }
  updateThumbnailPadding(index) {
    const _ = this;

    var pageWidth = document.body.offsetWidth / 2,
        elementWidth = (_.imagesThumbnails[index].object.parentNode.offsetWidth / 2),
        offsetLeft = _.imagesThumbnails[index].object.parentNode.offsetLeft;

    var offset = (pageWidth - _.imagesThumbnails[index].object.offset().left) - elementWidth;

    (_.lightbox.thumbnailWrapper).style.transform = 'translateX(' + offset + 'px)';
  }
}
const lightbox = LightBox.initAll();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console