Skip to content

Commit 98d841a

Browse files
ahmadilehamDexus
authored andcommitted
fix gravity width
1 parent 07fc45e commit 98d841a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

main/background.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ function placeParts(sheets, parts, config, nestindex){
10691069

10701070
// weigh width more, to help compress in direction of gravity
10711071
if(config.placementType == 'gravity'){
1072-
area = rectbounds.width*2 + rectbounds.height;
1072+
area = rectbounds.width*5 + rectbounds.height;
10731073
}
10741074
else{
10751075
area = rectbounds.width * rectbounds.height;
@@ -1110,19 +1110,18 @@ function placeParts(sheets, parts, config, nestindex){
11101110

11111111
if(
11121112
minarea === null ||
1113-
area < minarea ||
1114-
(GeometryUtil.almostEqual(minarea, area) && (minx === null || shiftvector.x < minx)) ||
1115-
(GeometryUtil.almostEqual(minarea, area) && (minx !== null && GeometryUtil.almostEqual(shiftvector.x, minx) && shiftvector.y < miny))
1113+
(config.placementType == 'gravity' && (
1114+
rectbounds.width < minwidth ||
1115+
(GeometryUtil.almostEqual(rectbounds.width, minwidth) && area < minarea)
1116+
)) ||
1117+
(config.placementType != 'gravity' && area < minarea) ||
1118+
(GeometryUtil.almostEqual(minarea, area) && shiftvector.x < minx)
11161119
){
11171120
minarea = area;
1118-
minwidth = rectbounds ? rectbounds.width : 0;
1121+
minwidth = rectbounds.width;
11191122
position = shiftvector;
1120-
if(minx === null || shiftvector.x < minx){
1121-
minx = shiftvector.x;
1122-
}
1123-
if(miny === null || shiftvector.y < miny){
1124-
miny = shiftvector.y;
1125-
}
1123+
minx = shiftvector.x;
1124+
miny = shiftvector.y;
11261125

11271126
if(config.mergeLines){
11281127
position.mergedLength = merged.totalLength;

0 commit comments

Comments
 (0)