简体   繁体   English

用两个手指手势实现水平滚动

[英]implementing horizontal scrolling with two finger gesture

I am trying to implement horizontal scrolling using a two finger gesture on laptops. 我正在尝试在笔记本电脑上使用两个手指的手势来实现水平滚动。 I am trying to find a solution that works in IE, chrome and safari. 我正在尝试找到在IE,Chrome和Safari浏览器中均可使用的解决方案。 Currently I have tried to using the mouse wheel event to simply capture the scrolling Event. 目前,我已经尝试使用鼠标滚轮事件来简单捕获滚动事件。 I thought I could use the deltaX and deltaY to determine if it is scrolling vertically and horizontally. 我以为我可以使用deltaX和deltaY来确定它是否垂直和水平滚动。

$('#ryan').on('mousewheel', function (event) {
    if (event.originalEvent.deltaX > 0) {
        console.log(event.originalEvent.deltaX);
        console.log("horizontally");
        console.log(event.deltaX);
}

Here is a fiddle which is not working. 这是一个无用的小提琴 I am also not sure if there is another event I am missing. 我也不确定是否还有其他事件想念。

I have never done it but jquery has a well documented element handler for scroll 我从没做过,但是jquery有一个文档齐全的滚动元素处理程序

I would try 我会尝试

$('#ryan').scroll(function(event) {
    if (event.originalEvent.deltaX > 0) {
        console.log(event.originalEvent.deltaX);
        console.log("horizontally");
        console.log(event.deltaX);
});

http://api.jquery.com/scroll/ http://api.jquery.com/scroll/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM