JQuery Scroll and collect value of middle element

雨燕双飞 提交于 2019-12-25 18:04:23

问题


I have set up 2 Fiddles. One is working perfectly. It is supposed to work out the middle value visible on screen.

The first fiddle performs this admirably on scroll.

The second incorporates a touch framework that does not work on scroll, but does work when you press the test button after scroll. This works on Google Chrome and Safari, but try it on Firefox. You will see it will not generate the correct value and stick at the bottom.

  • Working example :: http://jsfiddle.net/H3rHL/
  • Disfunctional :: http://jsfiddle.net/U4qyp/75/

Any ideas how to fix this.

Marvellous


回答1:


Try changing

$('#leftwheel').scroll(...);

to

$('#leftwheel').mousemove(...);

This won't be super-efficient, but will work OK for non-touch devices. See updated Fiddle

If you are looking to use this on touch devices, mousemove likely will not fire.



来源:https://stackoverflow.com/questions/6599835/jquery-scroll-and-collect-value-of-middle-element

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!