我正在制作一个图像滑块。当用户点击图片时:
- 图像滑动并出现在前面
- 在下一次单击时,图像被翻转并放大
- 在下一次单击时,图像会恢复到原来的大小和位置
在选择其他图像时,会发生相同的步骤。我想要做的是:假设我选择了一个图像并且图像翻转和放大。然后我直接点击另一张图片,所以我想写一个函数,在放大新图片之前,第一张图片应该恢复到原来的大小和位置。
这个怎么做?
var status=1;
function flipIt(obj){
//$(obj).wrap("<div class='centerImage'></div>")
console.log("value before Function status "+status);
if(status==1)
{
alert("i am From JS IF part");
$(obj).animate({"left": "-=30px","opacity": "0.65"},"slow");
$(obj).animate({"height":"400px","width":"350px"},30);
// initial w295 h354
$(obj).css("-webkit-transform-style","preserve-3d");
$(obj).css("-webkit-transition","all 1.0s linear");
$(obj).css("transform-style","preserve-3d");
$(obj).css("transition","all 1.0s linear");
$(obj).css("-webkit-transform","rotateY(180deg)");
$(obj).css("transform","rotateY(180deg)");
//$(obj).css("box-shadow","-5px 5px 5px #aaa");
status=0;
console.log("after if value set status "+status);
}
else
{
//alert("i am From JS Else part");
$(obj).animate({"left": "+=30px","opacity": "0.99"},"slow");
$(obj).animate({"height":"354px","width":"295px"},30);
$(obj).css("-webkit-transform-style","preserve-3d");
$(obj).css("-webkit-transition","all 1.0s linear");
$(obj).css("transform-style","preserve-3d");
$(obj).css("transition","all 1.0s linear");
$(obj).css("-webkit-transform","rotateY(0deg)");
$(obj).css("transform","rotateY(0deg)");
//alert("apply css");
status=1;
Removecss();
console.log("ater else value set status "+status);
}