Skip to content

Commit

Permalink
Merge pull request #2056 from VisActor/2054-bug-barToSide
Browse files Browse the repository at this point in the history
2054 bug getCellAtRelativePosition
  • Loading branch information
fangsmile committed Jul 9, 2024
2 parents 0d8319d + 1536290 commit 3ccfc47
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: getCellAtRelativePosition api return value #2054\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "[email protected]"
}
49 changes: 30 additions & 19 deletions packages/vtable/src/core/utils/get-cell-position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ export function getTargetColAtConsiderRightFrozen(
if (
isConsider &&
absoluteX > _this.tableNoFrameWidth - _this.getRightFrozenColsWidth() &&
absoluteX < _this.tableNoFrameWidth
absoluteX < _this.tableNoFrameWidth &&
absoluteX <= _this.getAllColsWidth()
) {
for (let i = 0; i < _this.rightFrozenColCount; i++) {
if (absoluteX > _this.tableNoFrameWidth - _this.getColsWidth(_this.colCount - i - 1, _this.colCount - 1)) {
Expand Down Expand Up @@ -377,12 +378,20 @@ export function getCellAtRelativePosition(x: number, y: number, _this: BaseTable

// bottom frozen
let bottomFrozen = false;
if (y > _this.tableNoFrameHeight - _this.getBottomFrozenRowsHeight() && y < _this.tableNoFrameHeight) {
if (
y > _this.tableNoFrameHeight - _this.getBottomFrozenRowsHeight() &&
y < _this.tableNoFrameHeight &&
y <= _this.getAllRowsHeight()
) {
bottomFrozen = true;
}
// right frozen
let rightFrozen = false;
if (x > _this.tableNoFrameWidth - _this.getRightFrozenColsWidth() && x < _this.tableNoFrameWidth) {
if (
x > _this.tableNoFrameWidth - _this.getRightFrozenColsWidth() &&
x < _this.tableNoFrameWidth &&
x <= _this.getAllColsWidth()
) {
rightFrozen = true;
}

Expand All @@ -396,20 +405,22 @@ export function getCellAtRelativePosition(x: number, y: number, _this: BaseTable
bottomFrozen,
_this
);

const { row, top, bottom, height } = rowInfo;
const { col, left, right, width } = colInfo;
const rect = {
left,
right,
top,
bottom,
width,
height
};
return {
row,
col,
rect
};
if (colInfo && rowInfo) {
const { row, top, bottom, height } = rowInfo;
const { col, left, right, width } = colInfo;
const rect = {
left,
right,
top,
bottom,
width,
height
};
return {
row,
col,
rect
};
}
return { col: -1, row: -1 };
}

0 comments on commit 3ccfc47

Please sign in to comment.