fix: Visibility and zooming when canvas offset is not zero (#2534)

This commit is contained in:
João Forja 2020-12-14 14:14:56 +00:00 committed by GitHub
parent 60864ace54
commit 4c7b1a2269
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 19 deletions

View file

@ -763,13 +763,20 @@ const isVisibleElement = (
) => {
const [x1, y1, x2, y2] = getElementBounds(element); // scene coordinates
const topLeftSceneCoords = viewportCoordsToSceneCoords(
{ clientX: 0, clientY: 0 },
{
clientX: viewTransformations.offsetLeft,
clientY: viewTransformations.offsetTop,
},
viewTransformations,
);
const bottomRightSceneCoords = viewportCoordsToSceneCoords(
{ clientX: canvasWidth, clientY: canvasHeight },
{
clientX: viewTransformations.offsetLeft + canvasWidth,
clientY: viewTransformations.offsetTop + canvasHeight,
},
viewTransformations,
);
return (
topLeftSceneCoords.x <= x2 &&
topLeftSceneCoords.y <= y2 &&