Skip to content

Commit

Permalink
fixed the center graph function again
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Wicenec committed Nov 7, 2024
1 parent c72628e commit e76731c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,17 +493,17 @@ export class Eagle {

//determine center of the display area
const displayCenterX : number = (containerWidth / that.globalScale() / 2);
const displayCenterY : number = containerHeight / that.globalScale() / 2;
const displayCenterY : number = (containerHeight / that.globalScale() / 2);

// translate display to center the graph centroid
that.globalOffsetX(Math.round(displayCenterX - centroidX + leftWindow));
that.globalOffsetY(Math.round(displayCenterY - centroidY));

//taking note of the screen center in graph space before zooming
const midPointX = $('#logicalGraphParent').width()/2
const midPointY = ($('#logicalGraphParent').height())/2
const xpb = midPointX/that.globalScale() - that.globalOffsetX();
const ypb = (midPointY)/that.globalScale() - that.globalOffsetY();
const midPointX = GraphRenderer.GRAPH_TO_SCREEN_POSITION_X(centroidX)

const xpb = centroidX
const ypb = displayCenterY/that.globalScale() - that.globalOffsetY();

//applying the correct zoom
if(graphYScale>graphXScale){
Expand All @@ -515,8 +515,8 @@ export class Eagle {
}

//checking the screen center in graph space after zoom
const xpa = midPointX/that.globalScale() - that.globalOffsetX();
const ypa = (midPointY)/that.globalScale() - that.globalOffsetY();
const xpa = GraphRenderer.SCREEN_TO_GRAPH_POSITION_X(midPointX)
const ypa = displayCenterY/that.globalScale() - that.globalOffsetY();

//checking how far the center has moved
const moveX = xpa-xpb
Expand Down

0 comments on commit e76731c

Please sign in to comment.