jQuery滚动并收集中间元素的值 [英] JQuery Scroll and collect value of middle element

查看:109
本文介绍了jQuery滚动并收集中间元素的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了2个小提琴.一个工作完美.应该计算出屏幕上可见的中间值.

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.

第二个组件合并了一个触摸框架,该框架在滚动时不起作用,但是在滚动后按测试按钮时才起作用.这适用于Google Chrome和Safari,但可以在Firefox上尝试.您会看到它不会生成正确的值,并停留在底部.

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.

奇妙

推荐答案

尝试更改

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

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

这不是超级高效,但是对于非触摸设备可以正常工作. 查看更新的小提琴

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

如果您希望在触摸设备上使用此功能,则mousemove可能不会触发.

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

这篇关于jQuery滚动并收集中间元素的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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