Topic: Scroll into view
webshapers priority asked 4 years ago
I want to add a class to an element, when it scrolls into view. Or maybe even do other weird things. Is there any chance to make use of existing resources, like a callback function or an additional attribute for the animations (data-animation-start="onScroll"). I'd like to know more about the libraries used. Thank you!
Grzegorz Bujański staff answered 4 years ago
I understand that this element is supposed to start animating when it appears on the screen after scrolling the page? Then you can use the event listener animationstart
and do whatever you want when the element starts animating.
const myElement = document.querySelector('#myElement');
myElement.addEventListener('animationstart', () => {
// do something
});
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: 2.2.1
- Device: any
- Browser: any
- OS: any
- Provided sample code: No
- Provided link: No