2017-06-19 52 views
0
@HostListener('window:scroll', ['$event']) 
    onWindowScroll() { 
    if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { 
     console.log('reached bottom'); 
    } 
    } 

這是代碼的工作如上,但它發生了很多次,甚至沒有達到完全結束的底部。如何檢查滾動是Angular 4底部的底部?

如何檢查wheather滾動到底到底?

回答

0
if (window.innerHeight + window.scrollY === document.body.scrollHeight) { 
     console.log('bottom'); 
} 

我發現了。