gpt4 book ai didi

dart - 使用Dart检测滚动到页面底部

转载 作者:行者123 更新时间:2023-12-03 02:51:16 25 4
gpt4 key购买 nike

我可以使用Javascript检测滚动到达底部

$(window).on("scroll", function() {
var scrollHeight = $(document).height();
var scrollPosition = $(window).height() + $(window).scrollTop();
if ((scrollHeight - scrollPosition) / scrollHeight === 0) {
// when scroll to bottom of the page
}
});

但是我在Dart中找不到document.height。
如何获取文档高度并与window.scrollY比较?

最佳答案

我认为,尽管我总是很难理解各种高度,但是document.body.clientHeight应该可以工作(即我曾经使用过一次)

_updateScrollInfo([_]) {
if (window.innerHeight + window.scrollY >= document.body.clientHeight) {
print("at bottom");
}
}
window.onScroll.listen(_updateScrollInfo);

DartPad示例: https://dartpad.dartlang.org/6fcfb715e4090a1aafe4

关于dart - 使用Dart检测滚动到页面底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32117121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com