Skip to content

Commit

Permalink
chore: custom offset start anchor for float dom
Browse files Browse the repository at this point in the history
  • Loading branch information
lumixraku committed Jan 17, 2025
1 parent 9bf375e commit 76bec15
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
10 changes: 4 additions & 6 deletions packages/sheets-drawing-ui/src/facade/f-worksheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ export interface IFWorksheetLegacy {
}, {
width: 100,
height: 30,
x: '100%',
y: '100%'},
marginX: '100%', // margin percent to range width, or pixel
marginY: '100%'
},
'AIButton') // dom id
}
Expand Down Expand Up @@ -129,11 +130,8 @@ export interface IFWorksheetLegacy {
props: {
a: 1,
},
data: {
aa: '128',
},
},
{width: 100, height: 40, x: 0, y: 0},
{width: 100, height: 40, marginX: 0, marginY: 0, horizonOffsetAlign: 'right'},
'ai-selector' // dom id
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ interface ICanvasFloatDomInfo {
export interface IDOMRangeLayout {
width: number;
height: number;
x?: number; // offsetX
y?: number; // offsetY
horizonOffsetAlign?: 'left' | 'right';
verticalOffsetAlign?: 'top' | 'bottom';
marginX?: number;
marginY?: number;
}

export interface ILimitBound extends IBoundRectNoAngle {
Expand Down Expand Up @@ -747,8 +749,8 @@ export class SheetCanvasFloatDomManagerService extends Disposable {
const domWidth = domPos.width ?? rangeWidth;
const domHeight = domPos.height ?? rangeHeight;

const domLeft = rangePosition.startX + calculateOffset(domPos.x, rangeWidth);
const domTop = rangePosition.startY + calculateOffset(domPos.y, rangeHeight);
const domLeft = rangePosition.startX + calculateOffset(domPos.marginX, rangeWidth);
const domTop = rangePosition.startY + calculateOffset(domPos.marginY, rangeHeight);

const sheetDrawingParam: ISheetFloatDom = {
unitId,
Expand Down Expand Up @@ -972,8 +974,22 @@ export class SheetCanvasFloatDomManagerService extends Disposable {
const domWidth = domLayout.width ?? rangeWidth;
const domHeight = domLayout.height ?? rangeHeight;

const domLeft = headerPosition.startX + calculateOffset(domLayout.x, rangeWidth);
const domTop = headerPosition.startY + calculateOffset(domLayout.y, rangeHeight);
let domLeft = 0;
let domTop = 0;
if (domLayout.horizonOffsetAlign === 'right') {
const offsetX = calculateOffset(domLayout.marginX, rangeWidth);
domLeft = headerPosition.endX - offsetX - domWidth;
} else {
// default align left
domLeft = headerPosition.startX + calculateOffset(domLayout.marginX, rangeWidth);
}

if (domLayout.verticalOffsetAlign === 'bottom') {
const offsetY = calculateOffset(domLayout.marginY, rangeHeight);
domTop = headerPosition.endY - offsetY - domHeight;
} else {
domTop = headerPosition.startY + calculateOffset(domLayout.marginY, rangeHeight);
}

const sheetDrawingParam: ISheetFloatDom = {
unitId,
Expand Down

0 comments on commit 76bec15

Please sign in to comment.