"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get rubberband () {
        return rubberband;
    },
    get rubberbandIfOutOfBounds () {
        return rubberbandIfOutOfBounds;
    }
});
var _bound = require("./bound");
function rubberband(distance, dimension, constant) {
    return distance * dimension * constant / (dimension + constant * distance);
}
function rubberbandIfOutOfBounds(position, min, max, dimension) {
    var constant = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 0.15;
    if (constant === 0) return (0, _bound.bound)(position, min, max);
    if (position < min) return -rubberband(min - position, dimension, constant) + min;
    if (position > max) return +rubberband(position - max, dimension, constant) + max;
    return position;
}
