I'm trying to use ScrollMagic library to use "Section Wipes" effect and i apply a color for every second div, using nth-child(even) but it doesn't seem to work with ScrollMagic. All boxes become white Html:
<div class="box" data="box-1"></div>
<div class="box" data="box-2"></div>
<div class="box" data="box-3"></div>
<div class="box" data="box-4"></div>
<div class="box" data="box-5"></div>
Css:
.box {
width: 100%;
height: 100vh;
display: grid;
place-items: center;
}
.box:nth-child(even) {
background-color: #ccc;
}
Javascript:
let boxes = document.querySelectorAll('.box');
let controller = new ScrollMagic.Controller({
globalSceneOptions: {
triggerHook: 'onLeave',
}
});
for (let i = 0; i < boxes.length; i++) {
new ScrollMagic.Scene({
triggerElement: boxes[i]
})
.setPin(boxes[i], )
.addTo(controller);
}
.box:nth-child(even)
won't work because .box
elements are not siblings anymore, they get wrapped by .scrollmagic-pin-spacer