Сообщение от ethereal
|
Как мне тот код внедрить в это:
|
document.addEventListener('DOMContentLoaded', function() {
const lazyAnimate = divs => {
divs.forEach(el => {
let isInView = el.intersectionRatio > .4;
let div = el.target;
if (div.classList.contains('site--image---video')) div.classList.toggle('show', isInView);
else {
if (isInView) {
div.play();
//$(div).bgVideo();
} else {
div.pause();
div.currentTime = 0;
}
}
});
}
let observer = new IntersectionObserver(lazyAnimate, {
rootMargin: "100px",
threshold: [0.1, 0.8] //настроить видимость
});
let container = document.querySelectorAll('.site--video, .site--image---video');
container.forEach(div => observer.observe(div))
});