jQuery: how to optimize/clean this basic animation code? -
I am trying to make the hand animation to attract the shape, it works fine, but the code is long and Does non-professional look it's any solution to make this animation short and professional?
Here's an example, my actual animation is too long, but it has the same idea:
  $ (hand) .mate ({top: 30, left: 255}, function () {$ (hand) .mate ({top: 130, left: 250}, function () {$ (hand) .mate ({top: 140, left: 265}, function () {$ (an_element). fadeOut ();});});});    Any suggestions?   
 
  You can write it as:  
  $ ( Hand) (top: 30, left: 255}). Value ({top: 130, left: 250}). Value ({top: 140, left: 265}, function () {$ (an_element). FedEight ();});     
  update:  
 You can also write it in this way:  
  handcurArr = [[30,255], [130,250], [140,265]]; (i = 0; i & lt; hand hirerr.langham; i ++) {$ (hand). Sammet (Top: Hand Coirer [i] [0], left: hand crow Array [i] [1]}); } / * 400 is the speed of the default animation * / $ (an_element) .delay (400 * handCoorArr.length). FadeOut ();     
  update 2:  
 with a specific delay for each step of the animation  
  handCoorArr = [[30,255,50], [130,250,800], [140,265,500]]; (I = 0; i & lt; handCoorArr.length; i ++) {$ (hand) for Sammet (Top: Hand Coourer [i] [0], left: Hand Coeur [I] [1]}, Hand Coeur [i] [2]]); } Hands ==; $ .eight ($ .mount (hand currier, function (V, I) {return v [2]}), function () {hand delay + = it;}); $ (An_element) .delay (handDelay) .fadeOut ();      
 
Comments
Post a Comment