当用户在页面底部滚动时,Javascript / JQuery执行功能 [英] Javascript/JQuery perform function when user scrolls near bottom of page

查看:133
本文介绍了当用户在页面底部滚动时,Javascript / JQuery执行功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个着名的新闻网站上(sry,不记得究竟是哪一个)我看到了一个非常酷的效果...当你在页面底部滚动时,一个新元素从浏览器视口的顶部向下滑动有很多社交媒体选项(推特,在Facebook上分享等)。我想模仿一些类似的东西......事实上,如果我知道当用户靠近页面底部时如何触发一个函数,我真的会想到很多事情......

On a prominent news site (sry, can't remember exactly which one) I saw a really cool effect... when you scroll near the bottom of the page, a new element slides down from the top of the browser viewport with a lot of social media options (tweet, share on facebook, etc). I'd like to emulate something somewhat similar... in fact, there's really a ton of things I could think of to do if I knew how to trigger a function when the user is near the bottom of the page...

所以,我的问题非常基本:当用户在动态大小的页面底部附近滚动时,如何触发一个函数?

So, my question is very basic: how does one trigger a function when the user has scrolled near the bottom of a dynamically sized page?

推荐答案

如果你的页面底部附近有一个元素,你可以使用 Waypoints 。或者,如果您想使用Hussein帖子中的像素限制,请务必留意我们从twitter学到的滚动课程

If you have an element thats near the bottom of the page, you can use Waypoints to trigger a function when the user scrolls to that element. Or if you want to use a pixel limit like in Hussein's post, make sure to heed the scroll lessons we learned from twitter

这篇关于当用户在页面底部滚动时,Javascript / JQuery执行功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆