Skip to content

Commit

Permalink
Prevent annotation dragging outside the visible page area
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed Feb 26, 2024
1 parent 71590c3 commit f050539
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pdf/pdf-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1891,8 +1891,9 @@ class PDFView {
let y = originalPagePosition.rects[0][1];

let viewBox = page.originalPage.viewport.viewBox;
x = x > viewBox[2] && viewBox[2] || x < viewBox[0] && viewBox[0] || x;
y = y > viewBox[3] && viewBox[3] || y < viewBox[1] && viewBox[1] || y;
const PADDING = 5;
x = x > (viewBox[2] - PADDING) && (viewBox[2] - PADDING) || x < (viewBox[0] + PADDING) && (viewBox[0] + PADDING) || x;
y = y > (viewBox[3] - PADDING) && (viewBox[3] - PADDING) || y < (viewBox[1] + PADDING) && (viewBox[1] + PADDING) || y;

let dp = [x - rect[0] - action.x, y - rect[1] - action.y];

Expand Down

0 comments on commit f050539

Please sign in to comment.