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-1.0.0.beta.7 app/assets/lookbook/js/helpers/layout.js
lookbook-1.0.0.beta.6 app/assets/lookbook/js/helpers/layout.js
lookbook-1.0.0.beta.5 app/assets/lookbook/js/helpers/layout.js
lookbook-1.0.0.beta.4 app/assets/lookbook/js/helpers/layout.js
lookbook-1.0.0.beta.3 app/assets/lookbook/js/helpers/layout.js
lookbook-1.0.0.beta.2 app/assets/lookbook/js/helpers/layout.js
lookbook-1.0.0.beta.1 app/assets/lookbook/js/helpers/layout.js
lookbook-1.0.0.beta.0 app/assets/lookbook/js/helpers/layout.js