jquery 用鼠标滚轮水平滚动
我目前有一个横向卷轴网站 (http://www.studioimbrue.com),我尝试绑定鼠标滚轮以横向滚动。目前,我正在使用 thehorizontalway.com 上找到的一个(称为 thw.js),但它似乎不适用于所有浏览器(Chrome)。
我正在尝试让这个工作: http://brandonaaron.net/code/mousewheel/docs ,只需滚动整个窗口,仅此而已。文档非常有限,所以我无法弄清楚。任何帮助表示赞赏。
I currently have a site that is a sidescroller (http://www.studioimbrue.com) and I'm trying to bind a mousewheel to scroll sideways. Currently I'm using the one found at thehorizontalway.com (called thw.js) but it doesn't seem to work in all browsers (Chrome).
I'm trying to get this one to work: http://brandonaaron.net/code/mousewheel/docs , to simply scroll the whole window, nothing else. There is very limited documentation so I can't figure it out. Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我刚刚回答了关于水平滚动 div 的这个问题,我还包括一些使用鼠标滚轮或仅用鼠标抓取和拖动的代码...也许其中一些代码会给您一个想法?
详细地说,鼠标滚轮函数为您提供事件对象和增量。
delta
的值取决于您滚动滚轮的速度。如果你真的很努力的话,我已经看到了从+50到-50的范围:PI just answered this question about scrolling a div horizontally, I also included some code to use the mousewheel or just grab and drag with the mouse... maybe some of that code will give you an idea?
To elaborate a bit, the mousewheel function gives you the event object and the delta.
The value of
delta
depends on how fast you scroll the wheel. I've seen a range from +50 to -50 if you try really hard :P我在注释中使用了 $(window).bind 方法,但它不会向后滚动,只能向前滚动,无论是在滚轮上向上还是向下滚动。
I used the $(window).bind approach in the comments but it wont scroll backwards, only forwards, for both up and down on the wheel.
上面评论中的解决方案有效,但仅当鼠标悬停在页面上的实际元素上时才有效。
当鼠标悬停在空白区域时(例如,如果您的内容非常短并且底部留有一些窗口),它将工作大约一个滚动,然后中断(直到您向左滚动),这就是为什么一个可能会认为滚动只有一种方式。人们为此推荐的所有花式滚动插件似乎也是这种情况。希望这可以帮助人们在未来找到解决方案。
This solution from the comments above works, but only when moused over the actual element on the page.
When just mousing over empty space (for example, if your content is very short and there's some window left over at the bottom) it'll work for about one scroll, and then break (until you scroll back left), which is why one might think that scrolling only works one way. This also seems to be the case with all of the fancy scroll plugins people recommend for this. Hopefully this helps people find a solution in the future.