【发布时间】:2015-01-03 07:31:14
【问题描述】:
我想要 3 个图块:上一个、当前、下一个。 例如,当用户从当前移动到下一个时,我希望添加一个新的下一个磁贴并删除旧的上一个磁贴。 有没有可以使用的特定javascript函数? 或者应该在哪个功能中实现? (在公园?) 任何想法,如何实现它? 谢谢
感谢 Jssor。它工作正常。供参考,这是我的“做某事治疗”
if (slideIndex > -1 && fromIndex > -1) {
// filter first access to keep only slide changement
var difference=slideIndex-fromIndex;
if (difference === 1 || difference === -2){
//next tile was just requested
var replaceIndex=(slideIndex+1)%3;
replaceImage(replaceIndex, nextImageUrl);
} else {
//previous tile was just requested
var replaceIndex=(2+slideIndex)%3;
replaceImage(replaceIndex, previousImageUrl);
}
}
function replaceImage(index,url){
// I have add the attributes class="tilei" where i = 0,1 or 2
// inside the tags <img u="image" ...
$('.tile'+index).attr("src",url).load(function(){
var fillHeight=this.height*720/this.width;
var top=(1130-fillHeight)/2;
$('.tile'+index).attr("style","width: 720px; height: "+fillHeight+
"px; top: "+top+"px; left: 0px; position: absolute;");
});
}
您是否会以另一种方式进行此图像替换以避免与 Jssor API 重复代码,或者阻止图像加载期间的任何交互?此致,迪迪埃
【问题讨论】:
标签: jssor