我有一个通过按钮单击向上补间的画布。我试图让它在补间结束后恢复,但它不起作用。它在屏幕顶部开始正常。我第一次单击该按钮时,它确实下降到 400,然后滑到 200。但是在下一次单击时 - 它只会继续向上飞行,而不是先回到 400。请帮忙!:)
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<script src=
"http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
</head>
<body>
<button onclick="func();">click</button> <canvas height="100" id="canvas"
style="position:absolute; top:50px; border:3px solid #000000;" width=
"200"></canvas>
<script>
var c = document.getElementById("canvas");
function func(){
c.style.top = 400 + "px";
TweenMax.to(c,2,{y: "-=200", onComplete:foo});
}
function foo(){
c.style.top = "400px";
}
</script>
</body>
</html>