Skip to content

Commit

Permalink
#2128 Automatically adjust zoom when opening a structure
Browse files Browse the repository at this point in the history
- added margin for structure autoscaling after import
  • Loading branch information
rrodionov91 committed Jul 18, 2023
1 parent 8ca2465 commit 007fc75
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/ketcher-react/src/script/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,15 @@ class Editor implements KetcherEditor {
const paper = this.render.paper;
const MIN_ZOOM_VALUE = 0.1;
const MAX_ZOOM_VALUE = 1;
const newZoomValue =
const MARGIN = 0.02;
let newZoomValue =
paper.height - clientAreaBoundingBox.height >
paper.width - clientAreaBoundingBox.width
? clientAreaBoundingBox.height / paper.height
: clientAreaBoundingBox.width / paper.width;

newZoomValue -= MARGIN;

if (newZoomValue < MAX_ZOOM_VALUE) {
this.zoom(
newZoomValue < MIN_ZOOM_VALUE
Expand Down

0 comments on commit 007fc75

Please sign in to comment.