Scroll into view


Topic: Scroll into view

webshapers pro premium priority asked 4 months 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 months 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
});

Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB 5
  • MDB Version: 2.2.1
  • Device: any
  • Browser: any
  • OS: any
  • Provided sample code: No
  • Provided link: No