$(function () {
$(".jqzoom").jqueryzoom({ xzoom: 630, yzoom: 630 });
$(".spec-scroll .items ul li img").mouseover(function () {
$(".jqzoom img").attr("src", $(this).attr("bimg"));
$(".jqzoom img").attr("jqimg", $(this).attr("bimg"));
});
var tempLength = 0; //臨時變量,當(dāng)前移動的長度
var viewNum = 4; //設(shè)置每次顯示圖片的個數(shù)量
var moveNum = 1; //每次移動的數(shù)量
var moveTime = 300; //移動速度,毫秒
var scrollDiv = $(".spec-scroll .items ul"); //進行移動動畫的容器
var scrollItems = $(".spec-scroll .items ul li"); //移動容器里的集合
var moveLength = scrollItems.eq(0).outerWidth(true) * moveNum; //計算每次移動的長度
var countLength = (scrollItems.length - viewNum) * scrollItems.eq(0).outerWidth(true); //計算總長度,總個數(shù)*單個長度
//下一張
$(".spec-scroll .next").bind("click", function () {
if (tempLength < countLength) {
if ((countLength - tempLength) > moveLength) {
scrollDiv.animate({ left: "-=" + moveLength + "px" }, moveTime);
tempLength += moveLength;
} else {
scrollDiv.animate({ left: "-=" + (countLength - tempLength) + "px" }, moveTime);
tempLength += (countLength - tempLength);
}
}
});
//上一張
$(".spec-scroll .prev").bind("click", function () {
if (tempLength > 0) {
if (tempLength > moveLength) {
scrollDiv.animate({ left: "+=" + moveLength + "px" }, moveTime);
tempLength -= moveLength;
} else {
scrollDiv.animate({ left: "+=" + tempLength + "px" }, moveTime);
tempLength = 0;
}
}
});
var productimg = new Swiper('.productimg', {
delay: 3000,
autoplay: true,
loop: true,
slidesPerView: 1,
spaceBetween: 0,
roundLengths: true,
navigation: {},
pagination: {
el: '.swiper-pagination',
clickable: true
},
breakpoints: {}
});
});