From 6efaceadea05a02135d41954907a73ffbff87f12 Mon Sep 17 00:00:00 2001 From: scriptspry Date: Thu, 1 Mar 2018 06:14:43 +0530 Subject: [PATCH] Fixed incorrect Object.isOnScreen functionality. (#4763) * Added missing calculate parameter in Object.isOnScreen. * Update object_geometry.js --- src/mixins/object_geometry.mixin.js | 4 ++-- test/unit/object_geometry.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mixins/object_geometry.mixin.js b/src/mixins/object_geometry.mixin.js index 8f30f7089f0..7c178f2e53f 100644 --- a/src/mixins/object_geometry.mixin.js +++ b/src/mixins/object_geometry.mixin.js @@ -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; diff --git a/test/unit/object_geometry.js b/test/unit/object_geometry.js index 21ea2ba0de6..956f1e2ad1c 100644 --- a/test/unit/object_geometry.js +++ b/test/unit/object_geometry.js @@ -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);