Skip to content

Commit

Permalink
Fixed incorrect Object.isOnScreen functionality. (fabricjs#4763)
Browse files Browse the repository at this point in the history
* Added missing calculate parameter in Object.isOnScreen.

* Update object_geometry.js
  • Loading branch information
scriptspry authored and asturur committed Mar 1, 2018
1 parent 8a6686a commit 6efacea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mixins/object_geometry.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@
}
}
// no points on screen, check intersection with absolute coordinates
if (this.intersectsWithRect(pointTL, pointBR, true)) {
if (this.intersectsWithRect(pointTL, pointBR, true, calculate)) {
return true;
}
// worst case scenario the object is so big that contains the screen
var centerPoint = { x: (pointTL.x + pointBR.x) / 2, y: (pointTL.y + pointBR.y) / 2 };
if (this.containsPoint(centerPoint, null, true)) {
if (this.containsPoint(centerPoint, null, true, calculate)) {
return true;
}
return false;
Expand Down
2 changes: 2 additions & 0 deletions test/unit/object_geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@
cObj.setCoords();
assert.ok(cObj.isOnScreen(), 'object is onScreen');
cObj.top = 1000;
assert.ok(cObj.isOnScreen(), 'object is still wrongly on screen since setCoords is not called and calculate is not set, even when top is already at 1000');
assert.ok(!cObj.isOnScreen(true), 'object is not onScreen with top 1000 with calculate true and no setCoords call');
cObj.setCoords();
assert.ok(!cObj.isOnScreen(), 'object is not onScreen with top 1000');
canvas.setZoom(0.1);
Expand Down

0 comments on commit 6efacea

Please sign in to comment.