I successfully used ScrollTrigger and the callback onEnter to trigger a function, but I'm having trouble when trying to trigger multiple elements with the same class. Before, when just triggering an animation for multiple elements of the same class, I would use the jQuery "each" function, but unfortunately it doesn't work in this scenario. This code below works:
const projectTitle = document.getElementById('bc-projects__heading');
const newerText = new functionName(projectTitle, {
timeOffset: 25,
callback: () => {
console.log('working')
}
});
function starterFx() {
newerText.start();
console.log('still working')
}
ScrollTrigger.create({
trigger: ".bc-projects__heading",
onEnter: starterFx,
delay: 3,
})
But when using the jQuery function with ScrollTrigger onEnter, it doesn't work:
const projectTitle = document.getElementById('bc-projects__heading');
const newerText = new functionName(projectTitle, {
timeOffset: 25,
callback: () => {
console.log('working')
}
});
function starterFx() {
newerText.start();
console.log('stillworking')
}
$(".bc-middle-main__heading").each(function() {
ScrollTrigger.create({
trigger: $(this),
onEnter: starterFx,
})
});
Am I calling the API with the wrong arguments?