in inflation-explorer/shared/js/scrollyteller.js [23:66]
checkScroll() {
if(this.lastScroll !== window.pageYOffset) {
const bbox = this.scrollText.getBoundingClientRect();
if(!supportsSticky) {
if(bbox.top <= 0 && bbox.bottom >= window.innerHeight) {
this.scrollInner.classed("fixed-top", true);
this.scrollInner.classed("absolute-bottom", false);
this.scrollInner.classed("absolute-top", false);
} else if(bbox.top <= 0) {
this.scrollInner.classed("fixed-top", false);
this.scrollInner.classed("absolute-bottom", true);
this.scrollInner.classed("absolute-top", false);
} else {
this.scrollInner.classed("fixed-top", false);
this.scrollInner.classed("absolute-bottom", false);
this.scrollInner.classed("absolute-top", true);
}
}
if(bbox.top < (window.innerHeight*(this.triggerTop)) && bbox.bottom > window.innerHeight/2) {
const i = Math.floor(Math.abs(bbox.top - (window.innerHeight*(this.triggerTop)))/bbox.height*this.textBoxes.length);
if(i !== this.lastI) {
this.lastI = i;
this.doScrollAction(i);
if(this.transparentUntilActive) {
this.textBoxes.forEach((el, j) => {
if(j <= i) {
el.style.opacity = "1";
} else {
el.style.opacity = "0.25";
}
});
}
}
}
this.lastScroll = window.pageYOffset;
}
window.requestAnimationFrame(this.checkScroll.bind(this));
}