javascript - other way how to toggle 2 function in jQuery -
i want toggle tweenmax when click tweenmax.to(con, 1, {height: '200px', ease:bounce.easeout});
here want:
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 animation height when click posible ? please help
you setup variable keep track when clicked:
this using functions:
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; });
or use tweens right in click handler:
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; });
Comments
Post a Comment