How to use the resize-observer-polyfill/src/ResizeObserver.js function in resize-observer-polyfill

To help you get started, we’ve selected a few resize-observer-polyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github que-etc / resize-observer-polyfill / src / app.js View on Github external
const hues = [
    'red',
    'pink',
    'blue',
    'orange',
    'purple',
    'monochrome'
];

let colorData = {
    luminosity: 'light',
    hue: hues[getRandomInt(0, 5)]
};

const observer = new ResizeObserver(entries => {
    for (const entry of entries) {
        const rect = entry.contentRect;
        const dimensionsStr = `${rect.width.toFixed(2)} x ${rect.height.toFixed(2)}`;

        entry.target.firstElementChild.textContent = dimensionsStr;
    }
});

let index = 0;
let queue = [];

function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

function updateColorData() {