Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
fix(praparat): fix zoom focal bug
Browse files Browse the repository at this point in the history
  • Loading branch information
itigoore01 committed Oct 3, 2019
1 parent 95f8f14 commit 60a8eba
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions projects/praparat/src/lib/praparat.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@ export class PraparatComponent implements OnDestroy, AfterViewInit {
clientY,
} = event;

const {
top,
left,
} = this.elementRef.nativeElement.getBoundingClientRect();

this.model.wheelZoom(deltaY, {
x: clientX,
y: clientY,
x: clientX - left,
y: clientY - top,
});
})
);
Expand Down Expand Up @@ -208,6 +213,8 @@ export class PraparatComponent implements OnDestroy, AfterViewInit {

zoomToFit(element: HTMLElement) {
const {
top: viewportTop,
left: viewportLeft,
width: viewportWidth,
height: viewportHeight,
} = this.elementRef.nativeElement.getBoundingClientRect();
Expand All @@ -222,8 +229,8 @@ export class PraparatComponent implements OnDestroy, AfterViewInit {
const currentScale = this.model.scale;
const currentPan = this.model.panPoint;

targetTop = targetTop / currentScale - currentPan.y;
targetLeft = targetLeft / currentScale - currentPan.x;
targetTop = (targetTop - viewportTop) / currentScale - currentPan.y;
targetLeft = (targetLeft - viewportLeft) / currentScale - currentPan.x;
targetWidth = targetWidth / currentScale;
targetHeight = targetHeight / currentScale;

Expand Down

0 comments on commit 60a8eba

Please sign in to comment.