在jquery中向上/向下滚动之间的区别? [英] Differentiate between scroll up/down in jquery?
本文介绍了在jquery中向上/向下滚动之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找到了一些使用 jquery 检查滚动条位置的好方法,但我想知道您是否可以区分用户是向上还是向下滚动?
I have found some great ways to check for where the scroll bar is using jquery, but I was wondering if you can differentiate whether or not the user scrolled up or down?
推荐答案
检查上次状态.像这样:
Check for the last state. Something like this:
保持一个变量,比如,last_scroll_position
,当你有一个滚动时,如果 last_scroll_position - current_position >0
,用户向上滚动,如果小于 0,则向下滚动.
Keep a variable, say, last_scroll_position
, and when you have a scroll, if last_scroll_position - current_position > 0
, the user scrolled up, and down if it's less than 0.
这篇关于在jquery中向上/向下滚动之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文