javascript - 水平画廊 - 滚动和触摸

标签 javascript jquery css wordpress gallery

我使用 NG Gallery 在 wordpress 上制作了水平画廊。

我想使用鼠标滚轮并通过单击画廊区域并移动来滚动画廊。 现在我只能通过单击图库底部的滚动条并手动移动来移动图像。 我怎样才能实现它?

这是我的自定义代码:

.ngg-galleryoverview {
  display: table-row;
  float: none;
  max-width: 100%;
  overflow-x: scroll;
  overflow-scrolling: touch;
  clear: both;
}

.ngg-gallery-thumbnail-box {
  display: table-cell;
  float: none;
}

.ngg-gallery-thumbnail {
    width: 415px;
}

最佳答案

添加这个它正在处理鼠标滚轮事件 library
去处理鼠标滚轮事件

$('#footer').on('mousewheel', function(event) {
    //console.log(event.deltaX, event.deltaY, event.deltaFactor);
    if(event.deltaY==1){
      $(this).animate({scrollLeft: '+=10px'}, 100);
    }else if(event.deltaY==-1){
        $(this).animate({scrollLeft: '-=10px'}, 100);
    }
});

fiddle

关于javascript - 水平画廊 - 滚动和触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44521655/

相关文章:

javascript - HTML5 Canvas 中的渐变位置

javascript - 使用位于插件文件夹内的参数执行二进制文件

javascript - 如何构建 Meteor 应用程序并加载到 Meteor shell 中

javascript - 使用 Ajax 弹出窗口进行基本身份验证登录?

css - 不使用绝对定位的 HTML 布局

css - 更少的 mixin 返回 Nanpx

javascript - 如何获取 Json 文档数组中数组的索引

javascript - 使用 html 和 javascript 将 href 值传递到另一个页面

javascript - 仅突出显示字符串中的匹配文本 (JQuery/Javascript)

javascript - 在 html 页面上更改鼠标光标