Skip to content

Commit bc46ceb

Browse files
Refactoring
1 parent 912404d commit bc46ceb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/js-draw/src/Editor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,14 @@ export class Editor {
458458

459459
if (!this.settings.allowOverscroll) {
460460
const imageRect = this.getImportExportRect();
461-
if (!this.viewport.visibleRect.intersects(imageRect)) {
462-
const visibleRectEdgePoint = this.viewport.visibleRect.getClosestPointOnBoundaryTo(
463-
imageRect.center,
464-
);
461+
const visibleRect = this.viewport.visibleRect;
462+
if (!visibleRect.intersects(imageRect)) {
463+
const visibleRectEdgePoint = visibleRect.getClosestPointOnBoundaryTo(imageRect.center);
465464
const imageRectEdgePoint = imageRect.getClosestPointOnBoundaryTo(visibleRectEdgePoint);
466465
const canvasDelta = visibleRectEdgePoint.minus(imageRectEdgePoint);
467466

468-
if (canvasDelta.length() > 1e-10) {
467+
const smallValue = 1e-10;
468+
if (canvasDelta.length() > smallValue) {
469469
this.viewport.resetTransform(evt.newTransform.rightMul(Mat33.translation(canvasDelta)));
470470
}
471471
}

0 commit comments

Comments
 (0)