Scroll event fire delay in mobile

2019-07-17 21:52发布

I got event listener to the scroll and everything works fine with desktop browsers(when scrolling starts - the event fired straight away) and chrome browser in mobile(chrome latest version + android version 5.0), but with other mobile browsers(ff, android browser) this works differently, and after googling for some I found the reason: it's because the scroll event is not fired until the scrolling action comes to a complete stop(releasing the finger from the screen).

My question is there some workaround for this, perhaps some best practice, so it will fire normally(as for desktop) and without dramatically performance changes?

*JS solution only(no for jquery).

2条回答
Summer. ? 凉城
2楼-- · 2019-07-17 22:06

I agree the answer of Mohit Bhardwaj and I just want to say some important thing about iScroll.

The iScroll runs depend on css3 translate and the js event such as touchMove, touchStart and touchEnd. You can just think it handle the whole scroll system in your page or the element container you set it to handle. One thing you should know, if you want to listen the scroll event in iScroll, you must import the iscroll-probe.js, and set the probeType param with 2 or 3. Otherwise you would not get the scroll event.

The iScroll version 5 is good, I use it in a lot of project. You can see it docs and code here

查看更多
不美不萌又怎样
3楼-- · 2019-07-17 22:29

You can use iScroll. It does not depend on jQuery and achieves what you want ( firing scroll events on mobile platforms ~continuously ) among other things.

You can refer to this answer for how to implement this using iScroll.

查看更多
登录 后发表回答