在单个页面上使用两个可滚动的 jQuery 工具实例

发布于 2024-12-03 05:37:29 字数 1466 浏览 2 评论 0原文

我在同一页面上有两个可滚动的 jQuery 实例。不幸的是,我认为存在一些覆盖和冲突。我如何修改以使它们能够一起正常工作?

//Scrollable for Social Sidebar area
    $(".socialScrollable").scrollable({ next:".socialNext", prev:".socialPrev", easing:"easeInOutCubic", vertical:true});
      var scrollable = jQuery(".socialScrollable").data("scrollable");
      var size = 3;
      scrollable.onSeek(function(event, index) {
        if (this.getIndex() >= this.getSize() - size) {
          jQuery("a.socialNext").addClass("disabled");
        }
      });
      scrollable.onBeforeSeek(function(event, index) {
        if (this.getIndex() >= this.getSize() - size) {
          if (index > this.getIndex()) {
            return false;
          }
        }
      });

第二组:

//Scrollables for Media page
$(".mediaScrollable").scrollable({ easing:"easeInOutCubic"}).navigator({navi:'#pressNavTabs'});

$("#mediaNavScrollable").scrollable({ easing:"easeInOutCubic", next:".nextMedia", prev:".prevMedia"});
  var mediaScrollable = jQuery("#mediaNavScrollable").data("scrollable");
  var mediaSize = 4;
  scrollable.onSeek(function(event, index) {
    if (this.getIndex() >= this.getSize() - mediaSize) {
      jQuery("a.nextMedia").addClass("disabled");
    }
  });
  scrollable.onBeforeSeek(function(event, index) {
    if (this.getIndex() >= this.getSize() - mediaSize) {
      if (index > this.getIndex()) {
        return false;
      }
    }
  });

I've got two instances of a jQuery scrollable on the same page. Unfortunately, I think there's some overwriting and collision going on. How do I modify to get them to both work together and properly?

//Scrollable for Social Sidebar area
    $(".socialScrollable").scrollable({ next:".socialNext", prev:".socialPrev", easing:"easeInOutCubic", vertical:true});
      var scrollable = jQuery(".socialScrollable").data("scrollable");
      var size = 3;
      scrollable.onSeek(function(event, index) {
        if (this.getIndex() >= this.getSize() - size) {
          jQuery("a.socialNext").addClass("disabled");
        }
      });
      scrollable.onBeforeSeek(function(event, index) {
        if (this.getIndex() >= this.getSize() - size) {
          if (index > this.getIndex()) {
            return false;
          }
        }
      });

Second set:

//Scrollables for Media page
$(".mediaScrollable").scrollable({ easing:"easeInOutCubic"}).navigator({navi:'#pressNavTabs'});

$("#mediaNavScrollable").scrollable({ easing:"easeInOutCubic", next:".nextMedia", prev:".prevMedia"});
  var mediaScrollable = jQuery("#mediaNavScrollable").data("scrollable");
  var mediaSize = 4;
  scrollable.onSeek(function(event, index) {
    if (this.getIndex() >= this.getSize() - mediaSize) {
      jQuery("a.nextMedia").addClass("disabled");
    }
  });
  scrollable.onBeforeSeek(function(event, index) {
    if (this.getIndex() >= this.getSize() - mediaSize) {
      if (index > this.getIndex()) {
        return false;
      }
    }
  });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

却一份温柔 2024-12-10 05:37:29

http://flowplayer.org/tools/demos/scrollable/site-navigation.html

他们有两个在同一页面上运行。也许是你的变量作用域有问题?

http://flowplayer.org/tools/demos/scrollable/site-navigation.html

They have two running on the same page here. Perhaps its a problem with your variable scoping?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文