@pdf-viewer/react
Version:
A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.
22 lines (21 loc) • 801 B
JavaScript
const d = (o, e, s, t = !1) => t ? o === 0 ? e === 0 ? 1 : -1 : 1 + (o - 1) * s + e + 1 : o * s + e + 1, g = (o, e, s = !1) => {
if (s) {
if (o === 1)
return { rowIndex: 0, columnIndex: 0 };
const n = o - 1 - 1, f = Math.floor(n / e) + 1, i = n % e;
return { rowIndex: f, columnIndex: i };
}
const t = o - 1, r = Math.floor(t / e), c = (t - r * e) % e;
return { rowIndex: r, columnIndex: c };
}, x = (o, e, s = !1) => {
const t = [], r = [];
return o.heights.forEach((c, a) => {
const n = g(a + 1, e, s), f = o.widths[a];
t[n.rowIndex] = Math.max(t[n.rowIndex] || 0, c), r[n.columnIndex] = Math.max(r[n.columnIndex] || 0, f);
}), { rowsHeight: t, columnsWidth: r };
};
export {
x as getGridDimension,
d as getPageFromPosition,
g as getPositionFromPage
};