Sha256: 2926b1a315023ad96a852201084457e7897ba74a35cf07aec6715db970eabbfc

Contents?: true

Size: 693 Bytes

Versions: 17

Compression:

Stored size: 693 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;
      setTimeout(() => {
        const scrollTop = parseInt(this.img.dataset.scrollTop, 10);
        if (!isNaN(scrollTop) && scrollTop !== 0) {
          this.modal.scrollTo(scrollTop);
        }
      }, 200);
    },

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

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
coveragebook_components-0.10.0 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.9.1 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.9.0 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.9 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.8 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.7 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.6 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.5 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.4 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.3 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.2 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.1 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.0 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.0.beta.3 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.0.beta.2 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.8.0.beta.1 app/components/coco/base/modal_lightbox/modal_lightbox.js
coveragebook_components-0.7.10 app/components/coco/base/modal_lightbox/modal_lightbox.js