Fix exported size when drawing to the left (#575)

If you scroll and draw to the left of the origin, when you export the scene, there's a weird whitespace on the right. This is because we do the min() computation starting at 0 and not -Infinity

This also fixes pasted elements and scrollbars.
This commit is contained in:
Christopher Chedeau authored and David Luzar committed 2020-01-26 12:28:15 +01:00
1 parent 4b0f788945
commit e1ed40be65
3 files changed
+6 -6

No files matched your search

+2 -2
View File
@@ -1382,9 +1382,9 @@ export class App extends React.Component<any, AppState> {
elements = clearSelection(elements);
let subCanvasX1 = Infinity;
let subCanvasX2 = 0;
let subCanvasX2 = -Infinity;
let subCanvasY1 = Infinity;
let subCanvasY2 = 0;
let subCanvasY2 = -Infinity;
const minX = Math.min(...parsedElements.map(element => element.x));
const minY = Math.min(...parsedElements.map(element => element.y));
+2 -2
View File
@@ -29,9 +29,9 @@ export function getExportCanvasPreview(
) {
// calculate smallest area to fit the contents in
let subCanvasX1 = Infinity;
let subCanvasX2 = 0;
let subCanvasX2 = -Infinity;
let subCanvasY1 = Infinity;
let subCanvasY2 = 0;
let subCanvasY2 = -Infinity;
elements.forEach(element => {
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
+2 -2
View File
@@ -14,9 +14,9 @@ export function getScrollBars(
scrollY: number,
) {
let minX = Infinity;
let maxX = 0;
let maxX = -Infinity;
let minY = Infinity;
let maxY = 0;
let maxY = -Infinity;
elements.forEach(element => {
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);