I am doing an animation where based on the scroll I change multiple background images of a main div amoled-section
. Hence, I am doing this by adding a class whenever the scroll hits a trigger e.g. #amoled-section-frame6
.Every time when trigger hits#amoled-section-frame6
it adds a class to amoled-section.on-frame6
.amoled-section.on-frame-6 {
background-image: url("https://image.shutterstock.com/image-photo/portrait-cheerful-male-architect-wearing-260nw-1060056851.jpg");
z-index: 1;
}
It was working all good until I observed that if I have a multiple image change it will require a time to download the image and will create a glitch effect. The problem that I want to resolve is somehow download background-images of divs before using them and in this way, the background image transition will work fine.
I attached in Codepen a link to the full code, however is not working probably because Srollmagic is not that flexible with Codepen. Link below.