检查用户是否滚动到Angular 2的底部(Check if user has scrolled to the bottom in Angular 2)

编程入门 行业动态 更新时间:2024-10-13 00:36:27
检查用户是否滚动到Angular 2的底部(Check if user has scrolled to the bottom in Angular 2)

检查用户是否在没有jQuery的情况下在Angular2中滚动到页面底部的最佳做法是什么? 我有权访问我的应用程序组件中的窗口吗? 如果不是,我应该检查滚动到页脚组件的底部,我该怎么做? 页脚组件上的指令? 有没有人完成这个?

What is the best practice to check if user has scrolled to the bottom of the page in Angular2 without jQuery? Do I have access to the window in my app component? If not should i check for scrolling to the bottom of the footer component, and how would I do that? A directive on the footer component? Has anyone accomplished this?

最满意答案

//你可以使用这个。

@HostListener("window:scroll", []) onScroll(): void { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { // you're at the bottom of the page } }

// You can use this.

@HostListener("window:scroll", []) onScroll(): void { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { // you're at the bottom of the page } }

更多推荐

本文发布于:2023-08-08 01:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466638.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户   Angular   Check   bottom   scrolled

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!