var lists = [ { width: "640px", height: "480px", top: "-150px", left: 0, z: 2, opacity: 0 }, { width: "640px", height: "480px", top: "60px", left: 0, z: 3, opacity: 0.6 }, { width: "800px", height: "600px", left: "200px", top: 0, z: 4, opacity: 1 }, { width: "640px", height: "480px", top: "60px", left: "560px", z: 3, opacity: 0.6 }, { width: "640px", height: "480px", top: "-150px", left: "560px", z: 2, opacity: 0 } ]; var lbt = $(".hxlbt"); var lbtLis = $(".hxlbt>.main>li"); var timer = null; var flag = true; var leftBtn = $(".hxlbt>a.leftBtn"); var rightBtn = $(".hxlbt>a.rightBtn"); var downOn = 2; var btmCir = $(".hxlbt>.down>li");
lbtFn(); function lbtFn() { $.each(lists, function(index, ele) { if (typeof ele != "undefined") { lbtLis .eq(index) .css("z-index", ele.z) .stop() .animate(ele, 500, function() { flag = true; }); } if (typeof ele == "undefined") { lists.splice(index, 1); } }); }
timer = setInterval(function() { lists.unshift(lists.pop()); lbtFn(); downOn = btnOnFn(); btmCir .eq(downOn) .addClass("on") .siblings() .removeClass("on"); }, 2000);
lbt.hover( function() { clearInterval(timer); leftBtn.css("display", "block"); rightBtn.css("display", "block"); }, function() { timer = setInterval(function() { lists.unshift(lists.pop()); lbtFn(); downOn = btnOnFn(); btmCir .eq(downOn) .addClass("on") .siblings() .removeClass("on"); }, 2000); leftBtn.css("display", "none"); rightBtn.css("display", "none"); } );
leftBtn.click(function() { if (flag) { flag = false; lists.push(lists.shift()); lbtFn(); downOn = btnOnFn(); btmCir .eq(downOn) .addClass("on") .siblings() .removeClass("on"); } }); rightBtn.click(function() { if (flag) { flag = false; lists.unshift(lists.pop()); lbtFn(); downOn = btnOnFn(); btmCir .eq(downOn) .addClass("on") .siblings() .removeClass("on"); } });
function btnOnFn() { var idx = 0; $.each(lists, function(index, ele) { if (typeof ele != "undefined") { if (ele.z == 4) { idx = index; return; } } }); return idx; }
btmCir.click(function() { var oldOn = btnOnFn(); var nowOn = $(this).index(); var newOn = oldOn - nowOn; if (newOn > 0) { for (var i = 0; i < newOn; i++) { lists.push(lists.shift()); } } if (newOn < 0) { for (var i = 0; i < -newOn; i++) { lists.unshift(lists.pop()); } } lbtFn(); $(this) .addClass("on") .siblings() .removeClass("on"); });
|