在单个页面上使用两个可滚动的 jQuery 工具实例
我在同一页面上有两个可滚动的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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?