Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ease(startValue, endValue, durationMs) {
- const stepCount = durationMs / 16; // how many steps will we take
- const stepSize = (endValue - startValue) / stepCount; // the size of each step
- let currentValue = startValue;
- function step() {
- currentValue += stepSize;
- if (currentValue < endValue) {
- // do something with currentValue
- window.requestAnimationFrame(step); // recursive call to step()
- }
- }
- step(); // kick things off
- }
Add Comment
Please, Sign In to add comment