Sha256: ff90c405a51a2835fceb7d2b5dd5b47dec76337008d071061b5942bf1136804e

Contents?: true

Size: 844 Bytes

Versions: 41

Compression:

Stored size: 844 Bytes

Contents

import "iframe-resizer/js/iframeResizer";

export default function embedComponent(id, embedStore) {
  if (!embedStore[id]) {
    embedStore[id] = { width: "100%", height: "100%" };
  }

  return {
    tab: "preview",

    resizer: null,

    get store() {
      return embedStore[id];
    },

    async loadResizer() {
      window.iFrameResize(
        {
          heightCalculationMethod: "lowestElement",
        },
        this.$el.querySelector("iframe")
      );
      this.resizer = this.$el.querySelector("iframe").iFrameResizer;
      this.resizer.resize();
      this.$dispatch("embed:resizer-loaded", { resizer: this.resizer });
    },

    resizeIframe() {
      this.$el.querySelector("iframe").iFrameResizer.resize();
    },

    cleanup() {
      if (this.resizer) {
        this.resizer.removeListeners();
      }
    },
  };
}

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
lookbook-1.5.5 app/components/lookbook/embed/component.js
lookbook-1.5.4 app/components/lookbook/embed/component.js
lookbook-1.5.3 app/components/lookbook/embed/component.js
lookbook-1.5.2 app/components/lookbook/embed/component.js
lookbook-1.5.1 app/components/lookbook/embed/component.js
lookbook-1.5.0 app/components/lookbook/embed/component.js
lookbook-1.4.5 app/components/lookbook/embed/component.js
lookbook-1.4.4 app/components/lookbook/embed/component.js
lookbook-1.4.3 app/components/lookbook/embed/component.js
lookbook-1.4.2 app/components/lookbook/embed/component.js
lookbook-1.4.1 app/components/lookbook/embed/component.js
lookbook-1.4.0 app/components/lookbook/embed/component.js
lookbook-1.3.4 app/components/lookbook/embed/component.js
lookbook-1.3.3 app/components/lookbook/embed/component.js
lookbook-1.3.1 app/components/lookbook/embed/component.js
lookbook-1.3.0 app/components/lookbook/embed/component.js
lookbook-1.2.1 app/components/lookbook/embed/component.js
lookbook-1.2.0 app/components/lookbook/embed/component.js
lookbook-1.1.1 app/components/lookbook/embed/component.js
lookbook-1.1.0 app/components/lookbook/embed/component.js