我试图在这个动画上使用回调,因此在动画完成后动画的图像会恢复到原始状态。但它不能正常工作。有人可以用正确的语法告诉我如何做到这一点吗?
if (currentEffect == "glimpse") {
$("#next").click(function () {
if (currentSlide == 0) {
$("#slide1").animate({
width: "0",
opacity: 0.2,
borderWidth: "10px"
}, 1000, function () {
width: "700px"
opacity: 100,
borderWidth: "0px"
});
$("#slide2").fadeIn(800);
}
});
}
答案 0 :(得分:1)
if (currentEffect == "glimpse") {
$("#next").click(function () {
if (currentSlide == 0) {
$("#slide1").animate({
width: "0",
opacity: 0.2,
borderWidth: "10px"
}, 1000, function () {
$(this).animate({ // <-- need to call .animate() again
width: "700px" // <--- you forgot a ,
opacity: 100, // <--- opacity is a value between 0.0 and 1.0
borderWidth: "0px"
}, 1000);
});
$("#slide2").fadeIn(800);
}
});
}
答案 1 :(得分:0)
回调函数未引用对象。你可能想要:
$("#slide1").animate({
width: "0",
opacity: 0.2,
borderWidth: "10px"
}, 1000, function () {
$("#slide1").css({
width: "700px",
opacity: 1,
borderWidth: "0px"
});
});