Sha256: b626c50c1d5b93284d113843ed86ebccb2efe6afa3922f4c050612ef9af73949

Contents?: true

Size: 692 Bytes

Versions: 5

Compression:

Stored size: 692 Bytes

Contents

import { CocoComponent } from "@js/coco";

export default CocoComponent("modalLightbox", () => {
  return {
    loaded: false,

    init() {
      if (this.img.complete && this.img.naturalHeight !== 0) {
        this.imageLoaded();
      }
    },

    close() {
      this.modal.hide();
    },

    imageLoaded() {
      this.loaded = true;
      this.$nextTick(() => {
        const scrollTop = parseInt(this.img.dataset.scrollTop, 10);
        if (!isNaN(scrollTop) && scrollTop !== 0) {
          this.modal.scrollTo(scrollTop);
        }
      });
    },

    get img() {
      return this.$refs.media.querySelector("img");
    },

    root: {
      ":class": "{loaded}",
    },
  };
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
coveragebook_components-0.7.9 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.7.8 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.7.7 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.7.6 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.7.5 app/components/coco/base/modal_lightbox/modal_lightbox.js