Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/js/aos.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ let options = {
// http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
const isBrowserNotSupported = () => document.all && !window.atob;

// current window scroll handler
let currentScrollHandler
const initializeScroll = function initializeScroll() {
// Extend elements objects in $aosElements with their positions
$aosElements = prepare($aosElements, options);
Expand All @@ -57,12 +59,13 @@ const initializeScroll = function initializeScroll() {
/**
* Handle scroll event to animate elements on scroll
*/
window.addEventListener(
'scroll',
throttle(() => {
handleScroll($aosElements, options.once);
}, options.throttleDelay)
);
if (currentScrollHandler) {
window.removeEventListener('scroll', currentScrollHandler)
}
currentScrollHandler = throttle(() => {
handleScroll($aosElements, options.once);
}, options.throttleDelay)
window.addEventListener('scroll', currentScrollHandler)

return $aosElements;
};
Expand Down