Skip to content

Commit bde4236

Browse files
committed
fix: zoom offset calc dont use cached value
1 parent e4f766b commit bde4236

2 files changed

Lines changed: 2 additions & 15 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-pdf-headless",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"type": "module",
55
"files": [
66
"src",

src/Reader.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -322,33 +322,20 @@ const Reader = ({
322322
onViewportsMeasured && onViewportsMeasured();
323323

324324
if (scrollAnchor) {
325-
// const startOffset = virtualizer.getOffsetForIndex(
326-
// scrollAnchor.index,
327-
// "start",
328-
// )?.[0];
325+
// manually calculate offset here in case it was cached from an earlier render
329326
const startOffset = getOffsetForIndexEager(
330327
scrollAnchor.index,
331328
virtualizer,
332329
estimateSize,
333330
);
334331

335-
console.log({ ...scrollAnchor });
336332
if (startOffset != null) {
337333
const itemHeight = estimateSize(scrollAnchor.index);
338334
const offset = getOffsetForIndexAndPercentage({
339335
itemHeight: itemHeight,
340336
percentage: scrollAnchor.percentageOffsetY,
341337
startOffset: startOffset,
342338
});
343-
const offsetExtra = itemHeight * scrollAnchor.percentageOffsetY * 0.01;
344-
console.log({
345-
wantPageIndex: scrollAnchor.index,
346-
startOffsetForPage: startOffset,
347-
itemHeight,
348-
percentage: scrollAnchor.percentageOffsetY,
349-
offsetExtra,
350-
offsetFinal: offset,
351-
});
352339

353340
virtualizer.scrollToOffset(offset, {
354341
align: "center",

0 commit comments

Comments
 (0)