Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorejb committed Oct 24, 2024
1 parent 315216f commit 8f054b9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions build/cropt.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,10 @@ export class Cropt {
const imgRect = this.elements.preview.getBoundingClientRect();
const vpRect = this.elements.viewport.getBoundingClientRect();
const transform = Transform.parse(this.elements.preview);
if (vpRect.top > imgRect.top + deltaY && vpRect.bottom < imgRect.bottom + deltaY) {
transform.y = transform.y + deltaY;
}
if (vpRect.left > imgRect.left + deltaX && vpRect.right < imgRect.right + deltaX) {
transform.x = transform.x + deltaX;
}
const clampedDeltaY = Math.max(Math.min(vpRect.top - imgRect.top, deltaY), vpRect.bottom - imgRect.bottom);
const clampedDeltaX = Math.max(Math.min(vpRect.left - imgRect.left, deltaX), vpRect.right - imgRect.right);
transform.y += clampedDeltaY;
transform.x += clampedDeltaX;
this.#updateCenterPoint(transform);
this.#updateOverlayDebounced();
}
Expand Down

0 comments on commit 8f054b9

Please sign in to comment.