UNPKG

@tdallau/nativescript

Version:

some helper functions for nativescript

31 lines 1.1 kB
import { promisify } from '@tdallau/helpers'; ; export function amountFromTo(range) { return function (t) { return range.from + t * (range.to - range.from); }; } export function animate(durration, animations) { var start = new Date(); return promisify(function (resolve, _reject) { var timerId = setInterval(function () { var timePassed = new Date().valueOf() - start.valueOf(); var progress = timePassed / durration; if (progress > 1) progress = 1; for (var _i = 0, animations_1 = animations; _i < animations_1.length; _i++) { var animation = animations_1[_i]; var delta = animation.curve(progress); var value = amountFromTo(animation.getRange())(delta); if (animation.condition()) { animation.draw(value); } } if (progress === 1) { clearInterval(timerId); resolve(); } }, 17); }); } //# sourceMappingURL=animate.js.map