Skip to content

Commit

Permalink
fix: overlapPadding not work in shiftY
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoluoHe committed Dec 20, 2024
1 parent 88c1c38 commit fe74328
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/vrender-components/src/label/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ export class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {
bitmap.setRange(range);
} else {
if (clampForce) {
const placedAfterClampForce = this._processClampForce(text as IText, bmpTool, bitmap);
const placedAfterClampForce = this._processClampForce(text as IText, bmpTool, bitmap, overlapPadding);
if (placedAfterClampForce) {
continue;
}
Expand All @@ -569,11 +569,11 @@ export class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {
return result;
}

protected _processClampForce(text: IText, bmpTool: BitmapTool, bitmap: Bitmap) {
protected _processClampForce(text: IText, bmpTool: BitmapTool, bitmap: Bitmap, overlapPadding = 0) {
const { dy = 0, dx = 0 } = clampText(text as IText, bmpTool.width, bmpTool.height, bmpTool.padding);
if (dx === 0 && dy === 0) {
if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
// xy方向偏移都为0,意味着不考虑 overlapPadding 时,实际上可以放得下
// 再次检查,若不考虑边界,仍然可以放得下,代表当前 text 没有与其他 text 重叠
if (canPlace(bmpTool, bitmap, text.AABBBounds, false, overlapPadding)) {
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
return true;
}
Expand Down Expand Up @@ -689,7 +689,7 @@ export class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {

// 尝试向内挤压
if (!hasPlace && clampForce) {
const placedAfterClampForce = this._processClampForce(text as IText, bmpTool, bitmap);
const placedAfterClampForce = this._processClampForce(text as IText, bmpTool, bitmap, overlapPadding);
if (placedAfterClampForce) {
result.push(text);
continue;
Expand Down

0 comments on commit fe74328

Please sign in to comment.