interpolate = function interpolate(update) {
    var complete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
    var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
    var delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;

    // no update function supplied -> exit
    if (!update) {
        return null;
    }

    // set start time
    var start = null;
    var t = void 0;
    var frame = null;

    // animation loop
    var tick = function tick(ts) {
        if (start === null) {
            start = ts;
        }

        t = ts - start - delay;

        if (t < duration) {
            update(t >= 0 ? t / duration : 0);
            frame = requestAnimationFrame(tick);
            return null;
        }

        update(1);

        if (complete) {
            complete();
        }
    };

    tick(now());

    // return cancel function
    return function () {
        cancelAnimationFrame(frame);
    };
}
interpolate between 0 and 1 over x amount of frames
@param update - update function
@param complete
@param duration - duration in milliseconds
@param delay - milliseconds to wait before starting