react-native-gallery-preview
Version:
<div> <img align="right" height="720" src="example.gif"> </div>
29 lines (25 loc) • 896 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.withRubberClamp = exports.clamp = void 0;
const clamp = (number, min, max) => {
"worklet";
return Math.max(min, Math.min(number, max));
};
exports.clamp = clamp;
const rubberClamp = (x, rubberStrength, dim) => {
"worklet";
return (1 - 1 / (x * rubberStrength / dim + 1)) * dim;
};
const withRubberClamp = (x, rubberStrength, dim, min, max) => {
"worklet";
const clampedX = clamp(x, min, max);
const diff = Math.abs(x - clampedX);
const direction = clampedX > x ? -1 : 1;
const _rubberStrength = typeof rubberStrength === "number" ? rubberStrength : direction === 1 ? rubberStrength.dir0 : rubberStrength.dir1;
const result = clampedX + direction * rubberClamp(diff, _rubberStrength, dim);
return result;
};
exports.withRubberClamp = withRubberClamp;
//# sourceMappingURL=clamp.js.map