Sha256: dd7d3ead3cbe51b64af7ff7660372434ecb1d7a74549e5ec9aaf8dfb7374237e

Contents?: true

Size: 666 Bytes

Versions: 68

Compression:

Stored size: 666 Bytes

Contents

function addMediaQueryListener(condition, callback) {
  const mediaQueryList = window.matchMedia(condition);
  const handleChange = (mql) => callback(mql.matches);
  handleChange(mediaQueryList);
  mediaQueryList.addEventListener("change", (mql) => handleChange(mql));
  return mediaQueryList;
}

function observeSize(element, callback = () => {}) {
  const observer = new ResizeObserver((entries) => {
    const rect = entries[0].target.getBoundingClientRect();
    callback({
      width: Math.round(rect.width),
      height: Math.round(rect.height),
    });
  });
  observer.observe(element);
  return observer;
}

export { addMediaQueryListener, observeSize };

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
lookbook-2.3.4 assets/js/helpers/layout.js
lookbook-2.3.3 assets/js/helpers/layout.js
lookbook-2.3.2 assets/js/helpers/layout.js
lookbook-2.3.0 assets/js/helpers/layout.js
lookbook-2.2.2 assets/js/helpers/layout.js
lookbook-2.2.1 assets/js/helpers/layout.js
lookbook-2.2.0 assets/js/helpers/layout.js
lookbook-2.1.1 assets/js/helpers/layout.js
lookbook-2.1.0 assets/js/helpers/layout.js
lookbook-2.0.5 assets/js/helpers/layout.js
lookbook-2.0.4 assets/js/helpers/layout.js
lookbook-2.0.3 assets/js/helpers/layout.js
lookbook-2.0.2 assets/js/helpers/layout.js
lookbook-2.0.1 assets/js/helpers/layout.js
lookbook-2.0.0 assets/js/helpers/layout.js
lookbook-2.0.0.rc.3 assets/js/helpers/layout.js
lookbook-1.5.5 app/assets/lookbook/js/helpers/layout.js
lookbook-1.5.4 app/assets/lookbook/js/helpers/layout.js
lookbook-2.0.0.rc.2 assets/js/helpers/layout.js
lookbook-2.0.0.rc.1 assets/js/helpers/layout.js