我想在点击TweenMax.to(con, 1, {height: '200px', ease:Bounce.easeOut});
时切换此tweenmax
这正是我想要的:
function One() {
TweenMax.to(con, 1, {height: '200px', ease:Bounce.easeOut});
}
function Two() {
TweenMax.from(con, 1, {height: '200px', ease:Bounce.easeOut});
}
$('.click').toggle(One, Two);
con是一个div,它会在点击时动画高度 这是真的吗?请帮忙
答案 0 :(得分:0)
你可以设置一个变量来跟踪它被点击的时间:
这是使用你的功能:
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;
});