1) { page = page - 1; }
if (flag == 3 && page < totalPage) { page = page + 1; }
if (flag == 4) { page = totalPage; }
$.ajax({
type: "GET",url: "@Url.Content("~/")home/teachers?t=" + new Date().valueOf(),data: { page: page },success: function (data) {
$('#teachers').html(data);
sliderImg();
}
});
}
//滚动
图片
function sliderImg() {
$(".products_next").click(function () {
if (_lock) return;
_lock = true;
var ul = $(this).parent().find("ul");
if (!canSlider(ul)) { _lock = false; return; }
var liFirst = ul.find("li:first");
var margin = liFirst.width() + 15;
var speed = margin * 3;
liFirst.animate({
marginLeft: 0 - margin
},speed);
setTimeout(function () {
liFirst.remove();
ul.append("
" + liFirst.html() + "");
_lock = false;
},speed);
});
$(".products_pre").click(function () {
if (_lock) return;
_lock = true;
var ul = $(this).parent().find("ul");
if (!canSlider(ul)) { _lock = false; return; }
var liLast = ul.find("li:last");
var margin = liLast.width() + 15;
var speed = margin * 3;
ul.prepend("
" + liLast.html() + "");
var liFirst = ul.find("li:first");
liFirst.animate({
marginLeft: 0
},speed);
setTimeout(function () {
liLast.remove();
_lock = false;
},speed);
});
}
//判断
图片是否可以滚动
function canSlider(ul) {
var width = 0;
ul.find("li").each(function () {
var li = $(this);
width = width + li.width() + 15;
});
if (width <= 710) {
return false;
}
return true;
}