I want that when user scrolls to that part of website animation triggers, means when that part comes in user's view the animation happens, here I am talking about the div class part 2, the part 1 working good but the part2 is not working, means animation works when website loads but at that time user is viewing part1 and when it scrolls to part 2, nothing happens as the animation has already happened when website was loaded. so please help me why it's not working.
Code Snippet
Код: Выделить всё
// Function to handle animation when elements are in view
const handleAnimation = () => {
const elements = document.querySelectorAll('.animate-slide-left-bg, .animate-slide-left, .animate-slide-right, .animate-slide-up');
elements.forEach(element => {
// Check if the element is in view
const rect = element.getBoundingClientRect();
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
if (rect.top >= 0 && rect.bottom
Источник: [url]https://stackoverflow.com/questions/78133396/the-slide-animation-is-not-working-when-scrolls-down[/url]
Мобильная версия