Advertisement
Guest User

hard-coding

a guest
Apr 29th, 2019
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. currMarg = (currMarg == 1800) ? (0) : (currMarg + 600);
  2. contStyle.marginLeft = "-%dpx".replace("%d", curMarg);
  3.  
  4. // Upon reading what this code does, I notice some hard-coding that could be done away with
  5.  
  6. const margMultiplier = -600;
  7. currMarg = ++currMarg % 4;
  8. contStyle.marginLeft = "%dpx".replace("%d", curMarg * margMultiplier);
  9.  
  10. // Much better. Result is 0->1->2->3->0->... versus 0->600->1200->1800->0->...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement