Skip to content

Commit

Permalink
better validation of dx and dy in getViewportAsRect
Browse files Browse the repository at this point in the history
Hopefully fix rare cases of x or y is NaN e.g. ome#453 (comment)
  • Loading branch information
will-moore committed Jul 7, 2022
1 parent 4501552 commit 46f4655
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/js/models/panel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,12 @@
zoom = zoom !== undefined ? zoom : this.get('zoom');
dx = dx !== undefined ? dx : this.get('dx');
dy = dy !== undefined ? dy : this.get('dy');
if (isNaN(parseInt(dx))) {
dx = 0;
}
if (isNaN(parseInt(dy))) {
dy = 0;
}
var rotation = this.get('rotation');

var width = this.get('width'),
Expand Down Expand Up @@ -516,7 +522,7 @@

// Use offset from image centre to calculate ROI position
var cX = orig_width/2 - dx,
cY = orig_height /2 - dy,
cY = orig_height/2 - dy,
roiX = cX - (roiW / 2),
roiY = cY - (roiH / 2);

Expand Down

0 comments on commit 46f4655

Please sign in to comment.