Skip to content

Commit

Permalink
Marks: fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
gdh1995 committed Apr 19, 2022
1 parent 29881d7 commit 4a2adeb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions web/vimium-c-injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,26 @@
if (!box) { return; }

var app = PDFViewerApplication;
var history = app.pdfHistory;
var pdfLoc = app.pdfViewer && app.pdfViewer._location;

if (!str) {
const hash = history && history._position && history._position.hash;
const hash = pdfLoc && pdfLoc.pdfOpenParams;
a.textContent = [box.scrollLeft, box.scrollTop, hash && "#" + hash.replace(/^#/, "") || null];
return;
}
const mark = str.split(",");
const x = ~~mark[0] - box.scrollLeft, y = ~~mark[1] - box.scrollTop
const x = ~~mark[0], y = ~~mark[1]
const hash = (mark.slice(2).join(",") || "").replace(/^#/, "").split("#")[0];
const dest = hash.includes("page=") ? new URLSearchParams(hash) : null;
const page = dest && +dest.get("page") || -1;
if (history && page >= 0) {
app.pdfLinkService.setHash(hash);
} else {
if (x || y) {
const dx = x - box.scrollLeft, dy = y - box.scrollTop
if (dx || dy) {
const zoom = dest ? dest.get("zoom") : "";
zoom && app.pdfViewer && (app.pdfViewer.currentScaleValue = zoom);
box.scrollTo(x, y);
box.scrollTo(dx, dy);
}
page >= 0 && typeof app.page === "number" && setTimeout(function() {
if (app.page !== page) {
Expand Down

0 comments on commit 4a2adeb

Please sign in to comment.