Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_triggerDidScrollDirection(contextEl = null, sensitivity = 1) {
assert('You must pass a valid context element to _triggerDidScrollDirection', contextEl);
assert('sensitivity cannot be 0', sensitivity);
const elementId = get(this, 'elementId');
const lastDirectionForEl = lastDirection[elementId];
const lastPositionForEl = lastPosition[elementId];
const newPosition = {
top: contextEl.scrollTop,
left: contextEl.scrollLeft
};
const scrollDirection = checkScrollDirection(lastPositionForEl, newPosition, sensitivity);
const directionChanged = scrollDirection !== lastDirectionForEl;
if (scrollDirection && directionChanged && get(this, 'viewportDidScroll')) {
this.trigger('didScroll', scrollDirection);
lastDirection[elementId] = scrollDirection;
}
lastPosition[elementId] = newPosition;
},