Sha256: 0473be9afe1dcd3f9420aa2b038ab90472a5aafb0beb5f862c80bf7269e10bcd

Contents?: true

Size: 837 Bytes

Versions: 44

Compression:

Stored size: 837 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(
          document.querySelector(targetSelector),
          ({ width, height }) => {
            this.width = width;
            this.height = height;
          }
        );
      }
    },

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

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
lookbook-1.2.1 app/components/lookbook/dimensions_display/component.js
lookbook-1.2.0 app/components/lookbook/dimensions_display/component.js
lookbook-1.1.1 app/components/lookbook/dimensions_display/component.js
lookbook-1.1.0 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.8 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.7 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.6 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.5 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.4 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.3 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.2 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.1 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.0 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.0.rc.3 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.0.rc.2 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.0.rc.1 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.0.beta.8 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.0.beta.7 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.0.beta.6 app/components/lookbook/dimensions_display/component.js
lookbook-1.0.0.beta.5 app/components/lookbook/dimensions_display/component.js