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