Анимация слайдов не работает при прокрутке внизCSS

Разбираемся в CSS
Ответить
Гость
 Анимация слайдов не работает при прокрутке вниз

Сообщение Гость »


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]
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «CSS»