Angular 如何检查滚动条是否位于角度4的底部?
这是工作的代码如上所述,但它发生了很多次,甚至没有达到到底 如何检查滚动条是否到达底部的末端Angular 如何检查滚动条是否位于角度4的底部?,angular,Angular,这是工作的代码如上所述,但它发生了很多次,甚至没有达到到底 如何检查滚动条是否到达底部的末端 @HostListener('window:scroll', ['$event']) onWindowScroll() { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { console.log('reached bottom'); } } 我找到了。
@HostListener('window:scroll', ['$event'])
onWindowScroll() {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
console.log('reached bottom');
}
}
我找到了。这对我很有用
if (window.innerHeight + window.scrollY === document.body.scrollHeight) {
console.log('bottom');
}
import { HostListener } from '@angular/core';
@HostListener('window:scroll', ['$event'])
onWindowScroll(event) {
// 200 is the height from bottom from where you want to trigger the infintie scroll, can we zero to detect bottom of window
if ((document.body.clientHeight + window.scrollY + 200) >= document.body.scrollHeight) {
console.log('tiggred');
}
}