mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 06:38:07 +02:00
Update the CaretBrowsingMode
toolbar-height if the toolbarDensity
preference changes (PR 18786 follow-up)
Otherwise the isVisible-calculations may not work correctly.
This commit is contained in:
parent
f2a132f826
commit
7c9d177826
2 changed files with 22 additions and 3 deletions
|
@ -876,6 +876,7 @@ const PDFViewerApplication = {
|
|||
|
||||
moveCaret(isUp, select) {
|
||||
this._caretBrowsing ||= new CaretBrowsingMode(
|
||||
this._globalAbortController.signal,
|
||||
this.appConfig.mainContainer,
|
||||
this.appConfig.viewerContainer,
|
||||
this.appConfig.toolbar?.container
|
||||
|
|
|
@ -19,14 +19,32 @@ const PRECISION = 1e-1;
|
|||
class CaretBrowsingMode {
|
||||
#mainContainer;
|
||||
|
||||
#toolBarHeight;
|
||||
#toolBarHeight = 0;
|
||||
|
||||
#viewerContainer;
|
||||
|
||||
constructor(mainContainer, viewerContainer, toolbarContainer) {
|
||||
constructor(abortSignal, mainContainer, viewerContainer, toolbarContainer) {
|
||||
this.#mainContainer = mainContainer;
|
||||
this.#viewerContainer = viewerContainer;
|
||||
this.#toolBarHeight = toolbarContainer?.getBoundingClientRect().height ?? 0;
|
||||
|
||||
if (!toolbarContainer) {
|
||||
return;
|
||||
}
|
||||
this.#toolBarHeight = toolbarContainer.getBoundingClientRect().height;
|
||||
|
||||
const toolbarObserver = new ResizeObserver(entries => {
|
||||
for (const entry of entries) {
|
||||
if (entry.target === toolbarContainer) {
|
||||
this.#toolBarHeight = Math.floor(entry.borderBoxSize[0].blockSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
toolbarObserver.observe(toolbarContainer);
|
||||
|
||||
abortSignal.addEventListener("abort", () => toolbarObserver.disconnect(), {
|
||||
once: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue