Skip to content

Commit e36f58e

Browse files
committed
Revert "Make horizontal padding relative to device width"
This reverts commit c138887.
1 parent 2dadac8 commit e36f58e

File tree

3 files changed

+4
-37
lines changed

3 files changed

+4
-37
lines changed

test/integration/find_spec.mjs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -149,32 +149,4 @@ describe("find bar", () => {
149149
);
150150
});
151151
});
152-
153-
describe("scrolls to the search result text for smaller viewports", () => {
154-
let pages;
155-
156-
beforeEach(async () => {
157-
pages = await loadAndWait("tracemonkey.pdf", ".textLayer", 100);
158-
});
159-
160-
afterEach(async () => {
161-
await closePages(pages);
162-
});
163-
164-
it("must scroll to the search result text", async () => {
165-
await Promise.all(
166-
pages.map(async ([browserName, page]) => {
167-
// Set a smaller viewport to simulate a mobile device
168-
await page.setViewport({ width: 350, height: 600 });
169-
await page.click("#viewFindButton");
170-
await page.waitForSelector("#findInput", { visible: true });
171-
await page.type("#findInput", "productivity");
172-
173-
const highlight = await page.waitForSelector(".textLayer .highlight");
174-
175-
expect(await highlight.isIntersectingViewport()).toBeTrue();
176-
})
177-
);
178-
});
179-
});
180152
});

web/pdf_find_controller.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const FindState = {
2929

3030
const FIND_TIMEOUT = 250; // ms
3131
const MATCH_SCROLL_OFFSET_TOP = -50; // px
32+
const MATCH_SCROLL_OFFSET_LEFT = -400; // px
3233

3334
const CHARACTERS_TO_NORMALIZE = {
3435
"\u2010": "-", // Hyphen
@@ -572,9 +573,10 @@ class PDFFindController {
572573
return;
573574
}
574575
this._scrollMatches = false; // Ensure that scrolling only happens once.
576+
575577
const spot = {
576578
top: MATCH_SCROLL_OFFSET_TOP,
577-
left: selectedLeft,
579+
left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT,
578580
};
579581
scrollIntoView(element, spot, /* scrollMatches = */ true);
580582
}

web/ui_utils.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,7 @@ function scrollIntoView(element, spot, scrollMatches = false) {
120120
offsetY += spot.top;
121121
}
122122
if (spot.left !== undefined) {
123-
const elementWidth = element.getBoundingClientRect().width;
124-
const padding = MathClamp(
125-
(parent.clientWidth - elementWidth) / 2,
126-
20,
127-
400
128-
);
129-
const left = spot.left - padding;
130-
offsetX += left;
123+
offsetX += spot.left;
131124
parent.scrollLeft = offsetX;
132125
}
133126
}

0 commit comments

Comments
 (0)