如何解决两个轮播js的相互干扰,请高手帮忙!

惆个小怅 2015-05-30 10:07:28
var i = 0;
jummper();
function jummper() {
$(".car ul li").eq(i).find("img").css("left", "-100%");
$(".car ul li").eq(i).find("p").css("width", "0%");
$(".car ul li").eq(i).find("img").animate({
left: "0"
},
500,
function() {
$(".car ul li").eq(i).find("p").animate({
width: "1260px"
},
5000,
function() {
$(".car ul li").eq(i).find("img").animate({
left: "100%"
},
500,
function() {
i++;
if (i > 2) i = 0;
$(".car ul li").eq(i).fadeIn(500).siblings().fadeOut(500)
})
})
})
}
setInterval("jummper()", 6500);
/*--------------------------------------------------------------------------*/
$(".picimglink").css("text-decoration", "none");
$(".picimglink").bind({
mouseenter: function() {
$(this).children("span").animate({
bottom: "0px"
},
500)
},
mouseleave: function() {
$(this).children("span").clearQueue().animate({
bottom: "-30px"
},
500)
}
});
var biZhiDelayLoadImg = $("#bigUl img");
var biZhiDelayLoadImgLength = biZhiDelayLoadImg.length;
for (var i = 3; i < biZhiDelayLoadImgLength; i++) {
var curDelayImg = biZhiDelayLoadImg.eq(i);
if (curDelayImg.attr("srch")) {
curDelayImg.attr("src", curDelayImg.attr("srch"));
curDelayImg.removeAttr("srch")
}
}
var _focus_num = $("#smallUl > li").length;
var _focus_direction = true;
var _focus_pos = 0;
var _focus_max_length = _focus_num * 720;
var _focus_li_length = 720;
var _focus_dsq = null;
var _focus_lock = true;
function autoExecAnimate() {
$("#mypic" + _focus_pos).addClass("info-cur").siblings("li.info-cur").removeClass("info-cur");
var moveLen = _focus_pos * _focus_li_length;
$("#bigUl").animate({
left: "-" + moveLen + "px"
},
600);
if (_focus_pos == (_focus_num - 1)) {
_focus_direction = false
}
if (_focus_pos == 0) {
_focus_direction = true
}
if (_focus_direction) {
_focus_pos++
} else {
_focus_pos--
}
}
_focus_dsq = setInterval("autoExecAnimate()", 6000);
$("#smallUl > li").hover(function() {
_focus_pos = parseInt($(this).attr("sid"));
if (_focus_lock) {
clearInterval(_focus_dsq);
_focus_lock = false
}
$("#mypic" + _focus_pos).addClass("info-cur").siblings("li.info-cur").removeClass("info-cur");
var moveLen = _focus_pos * _focus_li_length;
$("#bigUl").stop(true, true).animate({
left: "-" + moveLen + "px"
},
600)
},
function() {
if (_focus_lock == false) {
_focus_dsq = setInterval("autoExecAnimate()", 6000);
_focus_lock = true
}
});
$("#bigUl").hover(function() {
if (_focus_lock) {
clearInterval(_focus_dsq);
_focus_lock = false
}
},
function() {
if (_focus_lock == false) {
_focus_dsq = setInterval("autoExecAnimate()", 6000);
_focus_lock = true
}
});
$(".pic-list2 li").hover(function() {
$(this).addClass("hover").siblings().removeClass("hover")
},
function() {
$(this).removeClass("hover")
});
...全文
547 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
惆个小怅 2015-05-31
  • 打赏
  • 举报
回复
引用 1 楼 Inhibitory 的回复:
程序没法看,但是他们应该是使用了公共的变量或者信息,分开使用就好了。
回复:danielinbiti /*------------------**第一段-**-----------------------*/ var i = 0; jummper(); function jummper() { $(".car ul li").eq(i).find("img").css("left", "-100%");<!--滑动图片从左边的-100%(图片宽度)处滑出--> $(".car ul li").eq(i).find("p").css("width", "0%");<!--计时条宽度从0开始--> $(".car ul li").eq(i).find("img").animate({ left: "0" }, 500, <!--用时500毫秒将滑动图移到距左边为0的地方 function() { $(".car ul li").eq(i).find("p").animate({ width: "1260px" }, 5000, <!--计时条宽度1260px,用时5000毫秒--> function() { $(".car ul li").eq(i).find("img").animate({ left: "100%" }, 500, <!--用时500毫秒将滑动图移到距离左边为100%(图片宽度)的地方--> function() { i++; if (i > 2) i = 0; $(".car ul li").eq(i).fadeIn(500).siblings().fadeOut(500)<!--背景淡入淡出延时500毫秒--> }) }) }) } setInterval("jummper()", 6500);<!--总用时间--> /*------------------**第二段-**-----------------------*/ (function(){ $(".picimglink").css("text-decoration", "none"); $(".picimglink").bind({ mouseenter: function() { $(this).children("span").animate({ bottom: "0px"/*描述弹出距离底线的距离*/ }, 500)/*描述弹出时间500*/ }, mouseleave: function() { $(this).children("span").clearQueue().animate({ bottom: "-48px"/*描述退出的位置*/ }, 500)/*描述退出时间500*/ } }); var biZhiDelayLoadImg = $("#bigul img"); var biZhiDelayLoadImgLength = biZhiDelayLoadImg.length; for (var i = 3; i < biZhiDelayLoadImgLength; i++) { var curDelayImg = biZhiDelayLoadImg.eq(i); if (curDelayImg.attr("srch")) { curDelayImg.attr("src", curDelayImg.attr("srch")); curDelayImg.removeAttr("srch") } } var _focus_num = $("#smallUl > li").length; var _focus_direction = true; var _focus_pos = 0; var _focus_max_length = _focus_num * 720; var _focus_li_length = 720; var _focus_dsq = null; var _focus_lock = true; function autoExecAnimate() { $("#mypic" + _focus_pos).addClass("info-cur").siblings("li.info-cur").removeClass("info-cur"); var moveLen = _focus_pos * _focus_li_length; $("#bigul").animate({ left: "-" + moveLen + "px" }, 2000);/*滑到下一组图片所需要的时间600*/ if (_focus_pos == (_focus_num - 1)) { _focus_direction = false } if (_focus_pos == 0) { _focus_direction = true } if (_focus_direction) { _focus_pos++ } else { _focus_pos-- } } _focus_dsq = setInterval("autoExecAnimate()", 5000);/*轮播图片6秒滑动一次*/ $("#smallUl > li").hover(function() { _focus_pos = parseInt($(this).attr("sid")); if (_focus_lock) { clearInterval(_focus_dsq); _focus_lock = false } $("#mypic" + _focus_pos).addClass("info-cur").siblings("li.info-cur").removeClass("info-cur"); var moveLen = _focus_pos * _focus_li_length; $("#bigul").stop(true, true).animate({ left: "-" + moveLen + "px" }, 2000)/*鼠标动作-滑到鼠标指定的一组图片所需要的时间600*/ }, function() { if (_focus_lock == false) { _focus_dsq = setInterval("autoExecAnimate()", 5000);/*轮播图片6秒滑动一次*/ _focus_lock = true } }); $("#bigul").hover(function() { if (_focus_lock) { clearInterval(_focus_dsq); _focus_lock = false } }, function() { if (_focus_lock == false) { _focus_dsq = setInterval("autoExecAnimate()", 5000);/*轮播图片6秒滑动一次*/ _focus_lock = true } }); $(".pic-list2 li").hover(function() { $(this).addClass("hover").siblings().removeClass("hover") }, function() { $(this).removeClass("hover") }); })() 在第二段代码的两段加上 (function(){ …… })() 之后: 第一个轮播可以用了,而且比之前反应更迅速! 第二个的鼠标动作是可以用的,但是不能自动轮播。 **没加上之前是第一个完全不动的,第二个可以正常使用。** 您说的我完全不明白,本人比较菜鸟,请指教。 抱歉,最好麻烦您直接帮我修改,或者说得更具体一些。
Inhibitory 2015-05-31
  • 打赏
  • 举报
回复
程序没法看,但是他们应该是使用了公共的变量或者信息,分开使用就好了。

23,409

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧