Sha256: 0683af7a2bafa7adfc07e1c73d209737c5dbcb3a3415a1aa2114290107eda0a6

Contents?: true

Size: 774 Bytes

Versions: 24

Compression:

Stored size: 774 Bytes

Contents

import { observeSize } from "@helpers/layout";

export default function dimensionsDisplayComponent(targetSelector) {
  return {
    width: 0,
    height: 0,
    resizing: false,
    target: null,

    init() {
      this.target = document.querySelector(targetSelector);
      if (this.target) {
        this.width = Math.round(this.target.clientWidth);
        this.height = Math.round(this.target.clientHeight);
        this.createObserver();
      }
    },

    createObserver() {
      if (this.target) {
        this.observer = observeSize(this.target, ({ width, height }) => {
          this.width = width;
          this.height = height;
        });
      }
    },

    tearDown() {
      if (this.observer) {
        this.observer.disconnect();
      }
    },
  };
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
lookbook-2.3.4 app/components/lookbook/dimensions_display/component.js
lookbook-2.3.3 app/components/lookbook/dimensions_display/component.js
lookbook-2.3.2 app/components/lookbook/dimensions_display/component.js
lookbook-2.3.0 app/components/lookbook/dimensions_display/component.js
lookbook-2.2.2 app/components/lookbook/dimensions_display/component.js
lookbook-2.2.1 app/components/lookbook/dimensions_display/component.js
lookbook-2.2.0 app/components/lookbook/dimensions_display/component.js
lookbook-2.1.1 app/components/lookbook/dimensions_display/component.js
lookbook-2.1.0 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.5 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.4 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.3 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.2 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.1 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.0 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.0.rc.3 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.0.rc.2 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.0.rc.1 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.0.beta.9 app/components/lookbook/dimensions_display/component.js
lookbook-2.0.0.beta.8 app/components/lookbook/dimensions_display/component.js