锘?/鐐瑰嚮鎾斁浜嬩欢,x涓烘挱鏀捐棰戝湪瑙嗛鍒楄〃閲岀殑涓嬫爣 function showvideo(x) { var src = videolist[x]; //鎾斁鍔犺浇瑙嗛 if (videolist[x] != null) { ind = x; $(".video_grid_bg").show(); $(".video_grid").show(); myPlayer.src(src); myPlayer.load(src); myPlayer.play(); } } //鎾斁涓婁竴涓棰 function prevplay() { ind--; if (ind < 0) { ind = 0; } else { var src = videolist[ind]; myPlayer.src(src); myPlayer.load(); myPlayer.play(); } } //鎾斁涓嬩竴涓棰 function nextplay() { ind++; if (ind < videolist.length) { var src = videolist[ind]; myPlayer.src(src); myPlayer.load(); myPlayer.play(); } else { ind = videolist.length; } } var limit = Number($("#sidle_grid").attr("data-limt")); //鑾峰彇鑳芥椿鍔ㄦ樉绀虹殑涓暟 var length = $("#sidle_grid .sidle").length; //鑾峰彇鍒楄〃椤圭洰涓暟 var mid_limit = Math.ceil(limit / 2); //鑾峰彇娲诲姩鍒楄〃瑙嗗浘涓殑涓棿椤圭洰鐨勮瑙変笅鏍?1寮€濮? var mid = Math.ceil(length / 2); //鑾峰彇鍒楄〃椤圭洰涓腑闂撮」鐩殑瀹為檯涓嬫爣(1寮€濮? var left_limit = mid_limit - 1; //鑾峰彇娲诲姩鍒楄〃瑙嗗浘涓棿椤圭洰宸﹁竟鑳芥樉绀洪」鐩殑涓暟 var right_limit = limit - mid_limit; //鑾峰彇娲诲姩鍒楄〃瑙嗗浘涓棿椤圭洰鍙宠竟鑳芥樉绀洪」鐩殑涓暟 var unit_width = Number($("#sidle_grid .sidle").outerWidth()) + 15; //浣嶇Щ鍗曚綅璺濈 var maxleft = unit_width * (left_limit + 1); //宸︿晶瓒呭嚭瑙嗗浘鐨勮窛绂 var maxright = unit_width * (right_limit + 1); //鍙充晶瓒呭嚭瑙嗗浘鐨勮窛绂 var active = new Array(); //娲诲姩鏍囩ず鏁扮粍 var no_active = true; //鏄惁绌洪棽涓 var no_show_l = 2; //宸﹁竟娣″寲鍖轰釜鏁 var no_show_r = 2; //鍙宠竟娣″寲鍖轰釜鏁 //灏嗘暟鍊艰浆鎹㈡垚浠?寮€濮嬭鏁 limit = limit - 1; length = length - 1; mid_limit = mid_limit - 1; mid = mid - 1; $(function () { //鐓х墖澧欒疆鎾 //浣嶇疆鍒濆鍖 $("#sidle_grid .sidle").each(function (index, element) {//閬嶅巻鍒楄〃椤圭洰 if (index < mid) {//鍒ゆ柇鏄惁鍦ㄥ乏渚 if ((index + left_limit) >= mid) {//鍒ゆ柇鏄惁鍦ㄥ乏渚ц兘澶熸樉绀 $(element).css("left", "-" + (unit_width * (mid - index)) + "px"); active.push({ "id": index, "el": $(element) }); if ((index + left_limit) < (mid + no_show_l)) { $(element).css("opacity", "0.5"); } } else { $(element).css({ "left": "-" + maxleft + "px", "opacity": "0.5" }); } } else if (index == mid) { if (screen.width <= 1440) { $(element).css({ "height": "200px", "top": "0px" }); } else { $(element).css({ "height": "240px", "top": "0px" }); } active.push({ "id": index, "el": $(element) }); } else if (index > mid) {//鍒ゆ柇鏄惁鍦ㄥ彸渚 if ((index - right_limit) <= mid) {//鍒ゆ柇鏄惁鍦ㄥ彸渚ц兘澶熸樉绀 $(element).css("left", (unit_width * (index - mid)) + "px"); active.push({ "id": index, "el": $(element) }); if ((index - right_limit) > (mid - no_show_r)) { $(element).css("opacity", "0.5"); } } else { $(element).css({ "left": maxright + "px", "opacity": "0.5" }); } } }); if (length > limit) {//鑷姩 //var setInterval_ID = setInterval(sidle_left, 3500); $(".left_btn").click(function () { //clearInterval(setInterval_ID); sidle_left(); //setInterval_ID = setInterval(sidle_left, 3500); }); $(".right_btn").click(function () { //clearInterval(setInterval_ID); sidle_right(); //setInterval_ID = setInterval(sidle_left, 3500); }); //$(".sidle_btn").mousemove(function () { clearInterval(setInterval_ID) }); //$(".sidle_btn").mouseout(function () { setInterval_ID = setInterval(sidle_left, 3500); }); } else { $(".sidle_btn").hide(); } }); function sidle_left() {//宸︾Щ鍔 if (no_active) { no_active = false; var add = active[limit].id + 1; if (add > length) { add = 0; } $("#sidle_grid .sidle").eq(add).css("left", maxright + "px"); active.push({ "id": add, "el": $("#sidle_grid .sidle").eq(add) }); for (var i = 0; i < active.length; i++) { if (i == mid_limit) { if (screen.width <= 1440) { active[i].el.removeClass("curr").animate({ "left": "-=" + unit_width + "px", "height": "180px", "top": "10px" }, 800, function () { no_active = true; }); } else { active[i].el.removeClass("curr").animate({ "left": "-=" + unit_width + "px", "height": "200px", "top": "20px" }, 800, function () { no_active = true; }); } } else if (i == mid_limit + 1) { if (screen.width <= 1440) { active[i].el.addClass("curr").animate({ "left": "-=" + unit_width + "px", "height": "200px", "top": "0px" }, 800, function () { no_active = true; }); } else { active[i].el.addClass("curr").animate({ "left": "-=" + unit_width + "px", "height": "240px", "top": "0px" }, 800, function () { no_active = true; }); } } else if (i == no_show_l) { active[i].el.animate({ "left": "-=" + unit_width + "px", "opacity": "0.5" }, 800, function () { no_active = true; }); } else if (i == active.length - no_show_r - 1) { active[i].el.animate({ "left": "-=" + unit_width + "px", "opacity": "1" }, 800, function () { no_active = true; }); } else { active[i].el.animate({ "left": "-=" + unit_width + "px" }, 800, function () { no_active = true; }); } } active.shift(); } } function sidle_right() {//鍙崇Щ鍔 if (no_active) { no_active = false; var add = active[0].id - 1; if (add < 0) { add = length; } $("#sidle_grid .sidle").eq(add).css("left", "-" + maxleft + "px"); active.unshift({ "id": add, "el": $("#sidle_grid .sidle").eq(add) }); for (var i = 0; i < active.length; i++) { if (i == mid_limit + 1) { if (screen.width <= 1440) { active[i].el.removeClass("curr").animate({ "left": "+=" + unit_width + "px", "height": "180px", "top": "10px" }, 800, function () { no_active = true; }); } else { active[i].el.removeClass("curr").animate({ "left": "+=" + unit_width + "px", "height": "200px", "top": "20px" }, 800, function () { no_active = true; }); } } else if (i == mid_limit) { if (screen.width <= 1440) { active[i].el.addClass("curr").animate({ "left": "+=" + unit_width + "px", "height": "200px", "top": "0px" }, 800, function () { no_active = true; }); } else { active[i].el.addClass("curr").animate({ "left": "+=" + unit_width + "px", "height": "240px", "top": "0px" }, 800, function () { no_active = true; }); } } else if (i == no_show_l) { active[i].el.animate({ "left": "+=" + unit_width + "px", "opacity": "1" }, 800, function () { no_active = true; }); } else if (i == active.length - no_show_r - 1) { active[i].el.animate({ "left": "+=" + unit_width + "px", "opacity": "0.5" }, 800, function () { no_active = true; }); } else { active[i].el.animate({ "left": "+=" + unit_width + "px" }, 800, function () { no_active = true; }); } } active.pop(); } }