aos
aos copied to clipboard
Add "container" setting, to allow attaching AOS to any scrollable element
Related Issue
Issue: #223
Your solution
- Added
container
to AOS options (default: window). - Variable
container
is pointing toHTML Element
, or toWindow
if querySelector returns null. - EventListener is passing
container
tohandleScroll()
as a second argument -
handleScroll()
evaluates scroll distance by usingElement.scrollTop
orWindow.pageYOffset
Defining scrollable element
AOS.init({
container: ".scrollable-div"
})
How Has This Been Tested?
- By running included tests
In own projects, tested on:
- Desktop: Firefox 62, Chrome 71, Edge 42
- Android: Chrome, Firefox