react-broken-layouter
Version:
Layouter is a lightweight React utility for creating responsive masonry-style layouts.
25 lines (24 loc) • 709 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.heightEstimator = void 0;
exports.getRandomId = getRandomId;
exports.isObject = isObject;
const heightEstimator = (items) => {
let totalHeight = 0;
items.forEach((item) => {
if (typeof item === "string") {
totalHeight += item.length * 0.35;
}
else if (typeof item === "number") {
totalHeight += item;
}
});
return totalHeight;
};
exports.heightEstimator = heightEstimator;
function getRandomId() {
return Math.random().toString(36).substring(2, 9);
}
function isObject(item) {
return item && typeof item === "object" && !Array.isArray(item);
}
;