Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container flex items-center justify-center mx-auto">
  <div class="ta-gallery ta-gallery-aspect-hd mb-8 w-full" x-data="taGallery()" x-init="init()" data-start="0" data-timing="ease-in-out" data-duration="0.3s">
    <div class="ta-gallery-element ta-gallery-anim-swing rounded-lg ta-gallery-element-active">
      <figure>
        <img src="https://picsum.photos/800/500?random=1" alt="Example Image" class="ta-gallery-image" loading="lazy" x-ref="height">
        <figcaption class="ta-gallery-image-caption text-sm font-semibold text-white bg-gray-900 bg-opacity-25 bg-blur-2 px-4 py-1">
          Example Image
        </figcaption>
      </figure>
    </div>
    <div class="ta-gallery-element ta-gallery-anim-swing rounded-lg">
      <figure>
        <img src="https://picsum.photos/800/500?random=2" alt="Example Image" class="ta-gallery-image" loading="lazy" x-ref="height">
        <figcaption class="ta-gallery-image-caption text-sm font-semibold text-white bg-gray-900 bg-opacity-25 bg-blur-2 px-4 py-1">
          Example Image
        </figcaption>
      </figure>
    </div>

    <div class="ta-gallery-element ta-gallery-anim-slide flex-center bg-teal-200 bg-opacity-95 bg-blur-1 rounded-lg px-12 sm:px-24 py-8 sm:py-12">
      <div class="text-base sm:text-xl font-semibold text-gray-900 leading-relaxed text-center">
        Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nisi quasi incidunt dolorum cupiditate! Aut amet nesciunt, neque vitae non error culpa suscipit nobis placeat vel dolores earum dolore reiciendis consectetur?
      </div>
    </div>

    <div class="ta-gallery-background bg-gray-100 flex flex-col justify-center items-center rounded-lg text-center overflow-hidden shadow-xl">
      <div class="text-3xl font-bold text-gray-900 leading-normal w-2/3 opacity-75">
        Lorem ipsum dolor sit amet
      </div>
    </div>

    <button type="button" class="ta-gallery-button -left-5 sm:left-2 border-2 border-white bg-black bg-opacity-75 text-white rounded-full w-10 h-10 flex items-center justify-center shadow-xl focus:ring focus:ring-primary" x-on:click="previous()" x-show="loaded">
      <svg class="fill-current w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 512">
        <path d="M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z"></path>
      </svg>
    </button>
    <button type="button" class="ta-gallery-button -right-5 sm:right-2 border-2 border-white bg-black bg-opacity-75 text-white rounded-full w-10 h-10 flex items-center justify-center shadow-xl focus:ring focus:ring-primary" x-on:click="next()" x-show="loaded">
      <svg class="fill-current w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 512">
        <path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"></path>
      </svg>
    </button>

  </div>
</div>
              
            
!

CSS

              
                .ta-gallery {
  position: relative;
  min-height: var(--ta-gallery-min-height);
  max-width: var(--ta-gallery-width, 100%);
  max-height: var(--ta-gallery-height, 100%);
  perspective: 1000px;
  perspective-origin: center center;
}

.ta-gallery-size {
  width: var(--ta-gallery-width, 100%);
  height: var(--ta-gallery-height, 100%);
  min-height: var(--ta-gallery-min-height, 100%);
}

.ta-gallery-aspect-square {
  --ta-gallery-aspect-ratio: 1;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-movietone {
  --ta-gallery-aspect-ratio: 1.2;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-large {
  --ta-gallery-aspect-ratio: 1.25;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-tv {
  --ta-gallery-aspect-ratio: 1.333;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-academy {
  --ta-gallery-aspect-ratio: 1.375;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-imax {
  --ta-gallery-aspect-ratio: 1.43;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-classic {
  --ta-gallery-aspect-ratio: 1.5;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-still {
  --ta-gallery-aspect-ratio: 1.5;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-modern {
  --ta-gallery-aspect-ratio: 1.556;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-common {
  --ta-gallery-aspect-ratio: 1.6;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-golden {
  --ta-gallery-aspect-ratio: 1.618;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-super {
  --ta-gallery-aspect-ratio: 1.667;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-hd {
  --ta-gallery-aspect-ratio: 1.778;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-aspect-wide {
  --ta-gallery-aspect-ratio: 1.85;
  --ta-gallery-width: 100%;
  height: 0px;
  padding-bottom: calc(100% / var(--ta-gallery-aspect-ratio));
}

.ta-gallery-element {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
  animation-timing-function: var(--ta-galley-anim-timing, ease-in-out);
  animation-fill-mode: both;
  animation-duration: var(--ta-gallery-anim-duration, 0.3s);
  transform-origin: center center;
  backface-visibility: hidden;
  visibility: hidden;
  opacity: 0;
  --ta-gallery-anim-right-in: ta-gallery-slide-right-in;
  --ta-gallery-anim-right-out: ta-gallery-slide-right-out;
  --ta-gallery-anim-left-in: ta-gallery-slide-left-in;
  --ta-gallery-anim-left-out: ta-gallery-slide-left-out;
}

.ta-gallery-background {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
}

.ta-gallery-background-image {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
}

.ta-gallery-element-active {
  visibility: visible;
  z-index: 2;
  opacity: 1;
}

.ta-gallery-image {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  object-fit: cover;
  object-position: center center;
}

.ta-gallery-image-lazy {
  width: 20vw;
  max-width: 100px;
  height: 10rem;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.ta-gallery-button {
  position: absolute;
  top: 50%;
  z-index: 10;
  transform: translateY(-50%);
}

.ta-gallery-button-left {
  left: 0.5rem;
}

.ta-gallery-button-right {
  right: 0.5rem;
}

.ta-gallery-anim-swing {
  --ta-gallery-anim-right-in: ta-gallery-swing-right-in;
  --ta-gallery-anim-right-out: ta-gallery-swing-right-out;
  --ta-gallery-anim-left-in: ta-gallery-swing-left-in;
  --ta-gallery-anim-left-out: ta-gallery-swing-left-out;
}

.ta-gallery-anim-swipe {
  --ta-gallery-anim-right-in: ta-gallery-swipe-right-in;
  --ta-gallery-anim-right-out: ta-gallery-swipe-right-out;
  --ta-gallery-anim-left-in: ta-gallery-swipe-left-in;
  --ta-gallery-anim-left-out: ta-gallery-swipe-left-out;
}

.ta-gallery-anim-slide {
  --ta-gallery-anim-right-in: ta-gallery-slide-right-in;
  --ta-gallery-anim-right-out: ta-gallery-slide-right-out;
  --ta-gallery-anim-left-in: ta-gallery-slide-left-in;
  --ta-gallery-anim-left-out: ta-gallery-slide-left-out;
}

.ta-gallery-anim-rotate {
  --ta-gallery-anim-right-in: ta-gallery-rotate-right-in;
  --ta-gallery-anim-right-out: ta-gallery-rotate-right-out;
  --ta-gallery-anim-left-in: ta-gallery-rotate-left-in;
  --ta-gallery-anim-left-out: ta-gallery-rotate-left-out;
}

.ta-gallery-anim-snake {
  --ta-gallery-anim-right-in: ta-gallery-snake-right-in;
  --ta-gallery-anim-right-out: ta-gallery-snake-right-out;
  --ta-gallery-anim-left-in: ta-gallery-snake-left-in;
  --ta-gallery-anim-left-out: ta-gallery-snake-left-out;
  --ta-gallery-origin-right-in: right center;
  --ta-gallery-origin-right-out: left center;
  --ta-gallery-origin-left-in: left center;
  --ta-gallery-origin-left-out: right center;
}

.ta-gallery-anim-window {
  --ta-gallery-anim-right-in: ta-gallery-window-right-in;
  --ta-gallery-anim-right-out: ta-gallery-window-right-out;
  --ta-gallery-anim-left-in: ta-gallery-window-left-in;
  --ta-gallery-anim-left-out: ta-gallery-window-left-out;
  --ta-gallery-origin-right-in: right center;
  --ta-gallery-origin-right-out: left center;
  --ta-gallery-origin-left-in: left center;
  --ta-gallery-origin-left-out: right center;
}

.ta-gallery-anim-scroll {
  --ta-gallery-anim-right-in: ta-gallery-scroll-right-in;
  --ta-gallery-anim-right-out: ta-gallery-scroll-right-out;
  --ta-gallery-anim-left-in: ta-gallery-scroll-left-in;
  --ta-gallery-anim-left-out: ta-gallery-scroll-left-out;
  --ta-gallery-origin-right-in: right center;
  --ta-gallery-origin-right-out: left center;
  --ta-gallery-origin-left-in: left center;
  --ta-gallery-origin-left-out: right center;
}

.ta-gallery-anim-right-in {
  visibility: visible;
  transform-origin: var(--ta-gallery-origin-right-in);
  animation-name: var(--ta-gallery-anim-right-in, ta-gallery-right-in);
  animation-delay: calc(var(--ta-gallery-anim-duration) / 2);
}

.ta-gallery-anim-right-out {
  visibility: visible;
  transform-origin: var(--ta-gallery-origin-right-out);
  animation-name: var(--ta-gallery-anim-right-out, ta-gallery-right-out);
  animation-delay: 0s;
}

.ta-gallery-anim-left-in {
  visibility: visible;
  transform-origin: var(--ta-gallery-origin-left-in);
  animation-name: var(--ta-gallery-anim-left-in, ta-gallery-left-in);
  animation-delay: calc(var(--ta-gallery-anim-duration) / 2);
}

.ta-gallery-anim-left-out {
  visibility: visible;
  transform-origin: var(--ta-gallery-origin-left-out);
  animation-name: var(--ta-gallery-anim-left-out, ta-gallery-left-out);
  animation-delay: 0s;
}

.ta-gallery-image-caption {
  position: absolute;
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  width: 100%;
  z-index: 1;
}

@keyframes ta-gallery-swing-right-in {
  from: {
    opacity: 0;
    transform: scale(0.9) rotate3d(0, 1, 0, -90deg) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scale(1) rotate3d(0, 1, 0, 0deg) translateZ(0);
  }
}

@keyframes ta-gallery-swing-right-out {
  from: {
    opacity: 1;
    transform: scale(1) rotate3d(0, 1, 0, 0deg) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scale(0.9) rotate3d(0, 1, 0, 90deg) translateZ(0);
  }
}

@keyframes ta-gallery-swing-left-in {
  from: {
    opacity: 0;
    transform: scale(0.9) rotate3d(0, 1, 0, 90deg) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scale(1) rotate3d(0, 1, 0, 0deg) translateZ(0);
  }
}

@keyframes ta-gallery-swing-left-out {
  from: {
    opacity: 1;
    transform: scale(1) rotate3d(0, 1, 0, 0deg) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scale(0.9) rotate3d(0, 1, 0, -90deg) translateZ(0);
  }
}

@keyframes ta-gallery-slide-right-in {
  from: {
    opacity: 0;
    transform: scale(0.9) translateX(-100px) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scale(1) translateX(0) translateZ(0);
  }
}

@keyframes ta-gallery-slide-right-out {
  from: {
    opacity: 1;
    transform: scale(1) translateX(0) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scale(0.9) translateX(100px) translateZ(0);
  }
}

@keyframes ta-gallery-slide-left-in {
  from: {
    opacity: 0;
    transform: scale(0.9) translateX(100px) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scale(1) translateX(0) translateZ(0);
  }
}

@keyframes ta-gallery-slide-left-out {
  from: {
    opacity: 1;
    transform: scale(1) translateX(0) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scale(0.9) translateX(-100px) translateZ(0);
  }
}

@keyframes ta-gallery-swipe-right-in {
  from: {
    opacity: 0;
    transform: scale(1.1) translateX(-200px) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scale(1) translateX(0) translateZ(0);
  }
}

@keyframes ta-gallery-swipe-right-out {
  from: {
    opacity: 1;
    transform: scale(1) translateX(0) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scale(1.1) translateX(200px) translateZ(0);
  }
}

@keyframes ta-gallery-swipe-left-in {
  from: {
    opacity: 0;
    transform: scale(1.1) translateX(200px) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scale(1) translateX(0) translateZ(0);
  }
}

@keyframes ta-gallery-swipe-left-out {
  from: {
    opacity: 1;
    transform: scale(1) translateX(0) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scale(1.1) translateX(-200px) translateZ(0);
  }
}

@keyframes ta-gallery-rotate-right-in {
  from: {
    opacity: 0;
    transform: scale(0.9) rotate3d(1, 1, 0, -90deg) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scale(1) rotate3d(1, 1, 0, 0deg) translateZ(0);
  }
}

@keyframes ta-gallery-rotate-right-out {
  from: {
    opacity: 1;
    transform: scale(1) rotate3d(1, 1, 0, 0deg) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scale(0.9) rotate3d(1, 1, 0, 90deg) translateZ(0);
  }
}

@keyframes ta-gallery-rotate-left-in {
  from: {
    opacity: 0;
    transform: scale(0.9) rotate3d(1, 1, 0, 90deg) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scale(1) rotate3d(1, 1, 0, 0deg) translateZ(0);
  }
}

@keyframes ta-gallery-rotate-left-out {
  from: {
    opacity: 1;
    transform: scale(1) rotate3d(1, 1, 0, 0deg) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scale(0.9) rotate3d(1, 1, 0, -90deg) translateZ(0);
  }
}

@keyframes ta-gallery-snake-right-in {
  from: {
    opacity: 0;
    transform: scaleX(0.6) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scaleX(1) translateZ(0);
  }
}

@keyframes ta-gallery-snake-right-out {
  from: {
    opacity: 1;
    transform: scaleX(1) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scaleX(0.6) translateZ(0);
  }
}

@keyframes ta-gallery-snake-left-in {
  from: {
    opacity: 0;
    transform: scaleX(0.6) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scaleX(1) translateZ(0);
  }
}

@keyframes ta-gallery-snake-left-out {
  from: {
    opacity: 1;
    transform: scaleX(1) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scaleX(0.6) translateZ(0);
  }
}

@keyframes ta-gallery-scroll-right-in {
  from: {
    opacity: 0;
    transform: translateX(20vw) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: translateX(0) translateZ(0);
  }
}

@keyframes ta-gallery-scroll-right-out {
  from: {
    opacity: 1;
    transform: translateX(0) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: translateX(-20vw) translateZ(0);
  }
}

@keyframes ta-gallery-scroll-left-in {
  from: {
    opacity: 0;
    transform: translateX(-20vw) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: translateX(0) translateZ(0);
  }
}

@keyframes ta-gallery-scroll-left-out {
  from: {
    opacity: 1;
    transform: translateX(0) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: translateX(20vw) translateZ(0);
  }
}

@keyframes ta-gallery-window-right-in {
  from: {
    opacity: 0;
    transform: scale(0.9) rotate3d(0, 1, 0, -90deg) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scale(1) rotate3d(0, 1, 0, 0deg) translateZ(0);
  }
}

@keyframes ta-gallery-window-right-out {
  from: {
    opacity: 1;
    transform: scale(1) rotate3d(0, 1, 0, 0deg) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scale(0.9) rotate3d(0, 1, 0, 90deg) translateZ(0);
  }
}

@keyframes ta-gallery-window-left-in {
  from: {
    opacity: 0;
    transform: scale(0.9) rotate3d(0, 1, 0, 90deg) translateZ(0);
  }
  to: {
    opacity: 1;
    transform: scale(1) rotate3d(0, 1, 0, 0deg) translateZ(0);
  }
}

@keyframes ta-gallery-window-left-out {
  from: {
    opacity: 1;
    transform: scale(1) rotate3d(0, 1, 0, 0deg) translateZ(0);
  }
  to: {
    opacity: 0;
    transform: scale(0.9) rotate3d(0, 1, 0, -90deg) translateZ(0);
  }
}

              
            
!

JS

              
                window.taGallery = () => {
  return {
    previous_slide: 0,
    active_slide: 0,
    next_slide: 0,
    loaded: false,
    modal: false,
    timing: 0,
    interval: false,
    autoplay: false,
    class_names: {
      ri: "ta-gallery-anim-right-in",
      ro: "ta-gallery-anim-right-out",
      li: "ta-gallery-anim-left-in",
      lo: "ta-gallery-anim-left-out"
    },
    options: {
      item: "ta-gallery-element",
      size: "ta-gallery-size",
      active: "ta-gallery-element-active",
      lazy: "ta-gallery-image-lazy",
      minHeight: "10rem",
      start: 0,
      duration: "0.3s",
      origin: "center center",
      timing: "ease-in-out",
      autoplay: false,
      interval: 5000,
      pauseonhover: true
    },
    elements: [],
    init(values) {
      if (typeof values !== "undefined") {
        for (let [key, value] of Object.entries(values)) {
          this.options[key] = value;
        }
      }

      // checks if options are defined by data
      for (let [key, value] of Object.entries(this.$el.dataset)) {
        if (typeof this.options[key] !== "undefined") {
          this.options[key] = value;
        }
      }

      this.options.start = parseInt(this.options.start);
      if (this.options.start > 0) {
        this.options.start -= 1;
      }

      this.options.automatically =
        String(this.options.automatically).toLowerCase() === "true";
      this.options.pauseonhover =
        String(this.options.pauseonhover).toLowerCase() === "true";
      this.options.timing = parseInt(this.options.timing);

      this.setDuration(this.options.duration);
      this.setOrigin(this.options.origin);
      this.setTiming(this.options.timing);

      if (
        this.$el.classList.contains(this.options.size) &&
        this.options.minHeight != "false"
      ) {
        this.setMinHeight(this.options.minHeight);
      }

      var ref_obj = null;
      var ref_types = ["height", "width", "size"];
      var ref_type = "";
      var count_loaded = 0;

      ref_types.forEach((item) => {
        if (typeof this.$refs[item] !== "undefined") {
          ref_type = item;
          ref_obj = this.$refs[item];
          if (this.$refs[item].nodeName !== "IMG") {
            ref_obj = this.$refs[item].querySelector("img");
          }
          return;
        }
      });

      // if size defined image is not part of elements
      // set onload and resize after loaded
      if (ref_obj !== null) {
        if (!ref_obj.classList.contains(this.options.item)) {
          var ref_image_virtual = new Image();
          ref_image_virtual.src = ref_obj.src;
          ref_image_virtual.onload = (event) => {
            this.setSize(ref_type, event.target);
          };
        }
      }

      // get all items inside the gallery
      var items = this.$el.querySelectorAll("." + this.options.item);

      // walk through every element and create a virtual image for onload
      items.forEach((item) => {
        this.elements.push(item);

        // define image inside of item
        var image = item.querySelector("img");
        if (image === null) {
          count_loaded++;
          if (count_loaded >= this.elements.length) {
            this.loaded = true;
          }
          return;
        }

        // check if the image uses lazy loading
        var isLazy = false;
        if (
          image.classList.contains(this.options.lazy) &&
          typeof image.dataset.src !== "undefined"
        ) {
          isLazy = true;
          this.setMinHeight(this.options.minHeight);
        }

        // virtual image
        var image_virtual = new Image();
        image_virtual.onload = (event) => {
          // count the amount of images that are loaded and if
          // all images are loaded set param to true
          count_loaded++;
          if (count_loaded >= this.elements.length) {
            this.loaded = true;
          }

          const image_source = event.target.src;

          if (isLazy) {
            setTimeout((event) => {
              image.classList.remove(this.options.lazy);
              image.src = image_source;
            }, 0);
          }

          if (ref_obj !== null) {
            if (ref_obj.src === image_source) {
              this.setSize(ref_type, event.target);
            }
          }
        };

        // set the image src for the virtual image
        if (isLazy) {
          image_virtual.src = image.dataset.src;
        } else {
          image_virtual.src = image.src;
        }

        // remove animation classes after animation ended
        // important to have a borderless animation experience
        item.addEventListener("animationend", (event) => {
          console.info("end", event.animationName);
          const splited = event.animationName.split("-");
          splited[2] = "anim";
          event.target.classList.remove(splited.join("-"));
        });
      });
      this.elements[this.options.start].classList.add(this.options.active);
      this.active_slide = this.options.start;
      this.previous_slide = this.getPrevious();
      this.next_slide = this.getNext();

      if (this.options.autoplay) {
        this.setAutoplay();
      }

      this.$watch("modal", (value) => {
        var event_name = "ta-gallery-modal-hide";
        var event_object = {
          show: hide,
          index: this.active_slide,
          src: this.elements[this.active_slide].src
        };
        if (value === true) {
          event_name = "ta-gallery-modal-show";
          event_object.show = true;
        }
        const event = new CustomEvent(event_name, { detail: event_object });
        window.dispatchEvent(event);
      });
    },
    next() {
      this.previous_slide = this.active_slide;
      this.active_slide = this.getNext();
      this.next_slide = this.getNext();
      this.elements[this.active_slide].classList.remove(
        this.class_names.lo,
        this.class_names.li,
        this.class_names.ro
      );
      this.elements[this.active_slide].classList.toggle(this.options.active);
      this.elements[this.previous_slide].classList.toggle(this.options.active);
      this.elements[this.active_slide].classList.add(this.class_names.ri);
      this.elements[this.previous_slide].classList.add(this.class_names.ro);
      this.elements[this.previous_slide].classList.remove(
        this.class_names.lo,
        this.class_names.li,
        this.class_names.ri
      );
      this.timing = 0;
    },
    previous() {
      this.previous_slide = this.active_slide;
      this.active_slide = this.getPrevious();
      this.next_slide = this.getNext();
      this.elements[this.active_slide].classList.remove(
        this.class_names.ri,
        this.class_names.ro,
        this.class_names.lo
      );
      this.elements[this.active_slide].classList.toggle(this.options.active);
      this.elements[this.previous_slide].classList.toggle(this.options.active);
      this.elements[this.active_slide].classList.add(this.class_names.li);
      this.elements[this.previous_slide].classList.add(this.class_names.lo);
      this.elements[this.previous_slide].classList.remove(
        this.class_names.ri,
        this.class_names.ro,
        this.class_names.li
      );
      this.timing = 0;
    },
    stop() {
      clearInterval(this.interval);
    },
    pause() {
      this.autoplay = false;
    },
    resume() {
      this.autoplay = true;
    },
    togglePlay() {
      this.autoplay = !this.autoplay;
    },
    toggleModal() {
      this.modal = !this.modal;
    },
    getNext() {
      if (this.elements.length > this.active_slide + 1) {
        return this.active_slide + 1;
      }
      return 0;
    },
    getPrevious() {
      if (this.active_slide - 1 >= 0) {
        return this.active_slide - 1;
      }
      return this.elements.length - 1;
    },
    focusIsChild() {
      return this.$el.contains(document.activeElement);
    },
    setMinHeight(min_height) {
      this.$el.style.setProperty("--ta-gallery-min-height", min_height);
    },
    setDuration(duration) {
      this.$el.style.setProperty("--ta-gallery-anim-duration", duration);
    },
    setOrigin(origin) {
      this.$el.style.setProperty("--ta-gallery-anim-origin", origin);
    },
    setTiming(timing) {
      this.$el.style.setProperty("--ta-gallery-anim-timing", timing);
    },
    setSize(ref_type, image) {
      var aspect_ratio = image.naturalWidth / image.naturalHeight;
      if (ref_type === "height") {
        this.$el.style.setProperty("--ta-gallery-height", image.height + "px");
      } else if (ref_type === "width") {
        this.$el.style.setProperty("--ta-gallery-width", image.width + "px");
        this.$el.style.setProperty(
          "--ta-gallery-height",
          Math.floor(image.width / aspect_ratio) + "px"
        );
      } else if (ref_type === "size") {
        this.$el.style.setProperty("--ta-gallery-width", image.width + "px");
        this.$el.style.setProperty("--ta-gallery-height", image.height + "px");
      }
    },
    setAutoplay() {
      this.autoplay = true;
      this.interval = setInterval(() => {
        if (this.autoplay === false) {
          return;
        }
        this.timing += 1000;
        if (this.timing >= this.options.interval) {
          this.timing = 0;
          this.next();
        }
      }, 1000);
      if (this.options.pauseonhover) {
        this.$el.addEventListener("mouseover", () => {
          this.autoplay = false;
        });
        this.$el.addEventListener("mouseout", () => {
          if (!this.focusIsChild()) {
            this.autoplay = true;
          }
        });
      }
      window.addEventListener("focus", () => {
        if (!this.focusIsChild()) {
          this.autoplay = true;
        }
      });
      window.addEventListener("blur", () => {
        this.autoplay = false;
      });
    }
  };
};

              
            
!
999px

Console