do something as soon as soon as item get's class"swiper-slide-active" #4627
Unanswered
Fanni-Portier
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Maybe |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have short animations (mp4 files) inside of some of the swiper items.
I want them to start playing as soon as the item gets active.
No matter if the item stays in focus or the user scrolls away very quick - the animation should be triggerd.
Currently I use the "activeIndexChange"event.
On this event I detect all ".swiper-slide" items with class ".swiper-slide-active" and find the video element inside.
Then I trigger play with jquery.
My problem is, the animation just starts after the item loses the active class - because the event occurs in the moment the index changes - but the active class is not set in this moment.
So I added a very short timeout - but I guess and hope there is a better way to do this.
Can someone help?
I am working on it only local and with real client data - so I am sorry but I can not share my code here.
Beta Was this translation helpful? Give feedback.
All reactions