您可以设置一个变量来跟踪它被点击的时间:
这是使用您的功能:
function One() {
TweenMax.to(con, 1, {height: '200px', ease:Bounce.easeOut});
}
function Two() {
TweenMax.from(con, 1, {height: '200px', ease:Bounce.easeOut});
}
var clicked = false;
$(document).on('.click',function(){
var $this = $(this);
if(clicked === false){
One();
clicked = true;
} else if(clicked === true){
Two();
clicked = false;
}
return false;
});
或在点击处理程序中使用 Tweens:
var clicked = false;
$(document).on('.click',function(){
var $this = $(this);
if(clicked === false){
TweenMax.to(con, 1, {height: '200px', ease:Bounce.easeOut});
clicked = true;
} else if(clicked === true){
TweenMax.from(con, 1, {height: '200px', ease:Bounce.easeOut});
clicked = false;
}
return false;
});