Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
389 views
in Technique[技术] by (71.8m points)

javascript - 检测滚动结束/结束(Detecting scroll finish/end)

I'd like to detect when a user has stopped scrolling a page/element.(我想检测用户何时停止滚动页面/元素。)

This may be tricky as recently enhancements to OSX's scrolling behaviour creates this new inertia effect.(这可能是棘手的,因为最近OSX滚动行为的增强产生了这种新的惯性效果。) Is there an event fired?(是否有事件被触发?)

The only other solution I can think of is using a interval to pick up when the scroll position of a page/element no longer changes, for example:(我能想到的唯一其他解决方案是,当页面/元素的滚动位置不再更改时,使用间隔进行拾取,例如:)

var element     = $( el );
var previous    = element.scrollLeft();
var current;

element.scroll( function(event)
{
    current = element.scrollLeft();

    if ( current === previous )
    {
        // user has stopped scrolling
    }

    previous    = current;
});
  ask by Ahmed Nuaman translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Take a look at this , its jquery, and working well for me, hope to work for you.(看看this ,它的jquery对我来说很好,希望能为您工作。)

Also there is an other scroll event code in here .(也有在其他滚动事件代码在这里 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...