Guest User

Untitled

a guest
Jan 6th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. function ease(startValue, endValue, durationMs) {
  2. const stepCount = durationMs / 16; // how many steps will we take
  3. const stepSize = (endValue - startValue) / stepCount; // the size of each step
  4. let currentValue = startValue;
  5.  
  6. function step() {
  7. currentValue += stepSize;
  8.  
  9. if (currentValue < endValue) {
  10. // do something with currentValue
  11. window.requestAnimationFrame(step); // recursive call to step()
  12. }
  13. }
  14.  
  15. step(); // kick things off
  16. }
Add Comment
Please, Sign In to add comment