{
const myBars = example5.querySelectorAll('.scrolling-element');
function callback(entries, observer) {
entries.forEach(entry => {
if (entry.isIntersecting) {
const scale = Math.round((entry.intersectionRatio)*100)/100;
entry.target.style.transform = `scaleX(${scale})`;
}
});
}
const options = {
root: example5.querySelector('.frame'),
threshold: Array.apply(null, {length: 100}).map((n, i) => i/100)
}
const observer = new IntersectionObserver(callback, options);
Array.prototype.forEach.call(myBars, (el) => {
observer.observe(el);
});
}