Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private determineStatus(originalVals: StickyPositions, pageYOffset: number, marginTop: number, marginBottom: number, enabled: boolean) {
const elementPos = this.determineElementOffsets();
let isSticky = enabled && pageYOffset > originalVals.offsetY;
if (pageYOffset < this.elementOffsetY) {
isSticky = false;
}
const stickyElementHeight = this.getComputedStyle(this.stickyElement.nativeElement).height;
const reachedLowerEdge = isNotNullOrUndefined(this.boundaryElement) ? this.boundaryElement && window.pageYOffset + stickyElementHeight + marginBottom >= (originalVals.bottomBoundary - marginTop * 1.0) : undefined;
const reachedUpperEdge = isNotNullOrUndefined(this.boundaryElement) ? window.pageYOffset < (this.boundaryElement.offsetTop + marginTop * 1.0) : undefined;
this.stickyPosition.emit({...elementPos, upperScreenEdgeAt: pageYOffset, marginBottom, marginTop});
return {
isSticky,
reachedUpperEdge,
reachedLowerEdge,
};
}