Skip to content

Commit

Permalink
Add throttle and debounce delay options
Browse files Browse the repository at this point in the history
Simply adding more options so that users can configure the throttling/debouncing rates.
  • Loading branch information
lvmajor authored Apr 19, 2018
1 parent 836dbc0 commit c3a6216
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/js/aos.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ let options = {
duration: 400,
disable: false,
once: false,
startEvent: 'DOMContentLoaded'
startEvent: 'DOMContentLoaded',
throttleDelay: 99,
debounceDelay: 50
};

/**
Expand Down Expand Up @@ -145,15 +147,15 @@ const init = function init(settings) {
/**
* Refresh plugin on window resize or orientation change
*/
window.addEventListener('resize', debounce(refresh, 50, true));
window.addEventListener('orientationchange', debounce(refresh, 50, true));
window.addEventListener('resize', debounce(refresh, options.debounceDelay, true));
window.addEventListener('orientationchange', debounce(refresh, options.debounceDelay, true));

/**
* Handle scroll event to animate elements on scroll
*/
window.addEventListener('scroll', throttle(() => {
handleScroll($aosElements, options.once);
}, 99));
}, options.throttleDelay));

/**
* Observe [aos] elements
Expand Down

0 comments on commit c3a6216

Please sign in to comment.