// 基于jq,根据其他框架自行改动
// (商品总数, 视口能显示的数量, 视口宽度 , 翻页方向 , 需要移动的元素)
function pageTurn(amount, size, width, direction , target) {
var page = Math.ceil(amount / size)
if(!this.turnNum){
this.turnNum =0
}
if(direction == 'left'){
this.turnNum > 0 ? this.turnNum-- : 1;
}else {
this.turnNum < page-1 ? this.turnNum++ : page-1;
}
console.log(this.turnNum)
$(target).css('transform', `translateX(${0 - this.turnNum*width}px)`);
}
// 调用 argey
$(".pageTurnR").click(function(){
pageTurn(100, 5 , 1120, 'right' , $(".Target"));
})
简单的产品轮播函数
最新推荐文章于 2022-06-13 18:42:25 发布