2017-06-19 49 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'); 
} 

我发现了。