My website has a background animation that controls various shapes, each with their own unique animation styles:
animation: animShape 50s linear infinite;
The speed of the animations varies depending on the shape being displayed.
The animShape keyframes are defined as follows:
animShape {
from {
transform: translateY(0px);
}
to {
transform: translateY(-2000px);
}
}
I am looking to adjust the speed of each shape (represented by div elements) based on the scroll position.
I have been considering different approaches and was hoping for some guidance in the right direction.
Here's an idea I had:
$(document).on('scroll', '#section-trigger' , function(){
$("#first-shape").removeClass('.first-animation-class');
$("#first-shape").addClass('.second-animation-class');})
$(document).on('scroll', '#another-section-trigger', function() {
$("#first-shape").removeClass('.second-animation-class');
$("#first-shape").addClass('first-animation-class');})
...
However, this approach would require me to create separate animation classes for each shape, which might not be the most efficient way to handle it.
Another option could be utilizing JQuery to manage all the animations, but I've read that it may not have direct access to :after elements. Any workarounds for this issue?
Apologies if the formatting is off – sometimes it gets confusing. Appreciate any help!