0

单击此处时,我想切换此 tweenmaxTweenMax.to(con, 1, {height: '200px', ease:Bounce.easeOut}); 正是我想要的:

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,它会在点击时动画高度这可能吗?请帮忙

4

1 回答 1

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;
});
于 2013-11-15T16:31:21.970 回答