mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Attempt to respect the "zoom" hash parameter, even when the "nameddest" parameter is present (issue 11875)
Given that the `PDFLinkService.setHash` method itself if completely synchronous, moving the handling of "nameddest" to occur last *shouldn't* cause any problems (famous last words). This way the destination will still override any previous parameter, such as e.g. the "page", as expected. Furthermore, given that the `PDFLinkService.navigateTo` method is asynchronous that should provide additional guarantees that the "nameddest" parameter is always respected. As sort-of expected, this fairly innocent looking change also required some tweaks in the `PDFHistory` to prevent dummy history entires upon document load (only an issue when both "page" *and* "nameddest" parameters are provided in the hash).
This commit is contained in:
parent
491904d30a
commit
af1bb04662
2 changed files with 15 additions and 8 deletions
|
@ -233,10 +233,6 @@ class PDFLinkService {
|
|||
});
|
||||
}
|
||||
// borrowing syntax from "Parameters for Opening PDF Files"
|
||||
if ("nameddest" in params) {
|
||||
this.navigateTo(params.nameddest);
|
||||
return;
|
||||
}
|
||||
if ("page" in params) {
|
||||
pageNumber = params.page | 0 || 1;
|
||||
}
|
||||
|
@ -308,6 +304,11 @@ class PDFLinkService {
|
|||
mode: params.pagemode,
|
||||
});
|
||||
}
|
||||
// Ensure that this parameter is *always* handled last, in order to
|
||||
// guarantee that it won't be overridden (e.g. by the "page" parameter).
|
||||
if ("nameddest" in params) {
|
||||
this.navigateTo(params.nameddest);
|
||||
}
|
||||
} else {
|
||||
// Named (or explicit) destination.
|
||||
dest = unescape(hash);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue