Skip to content

Commit

Permalink
#6184 grid.View: updateVisibleColumns()
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiu committed Jan 7, 2025
1 parent 6f3f03d commit 618ab2a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/grid/Container.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ class GridContainer extends BaseContainer {
console.log(this.mounted, data);
await me.passSizeToView(true);

me.view.updateVisibleColumns();

me.headerToolbar.passSizeToView()
}

Expand Down
51 changes: 30 additions & 21 deletions src/grid/View.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -258,28 +258,10 @@ class GridView extends Component {
* @protected
*/
afterSetScrollPosition(value, oldValue) {
let me = this,
countColumnPositions = me.columnPositions.length;

if (value.x !== oldValue?.x && countColumnPositions > 0) {
let i = 0,
endIndex = countColumnPositions - 1,
column, startIndex;

for (; i < countColumnPositions; i++) {
column = me.columnPositions[i];

if (value.x >= column.x && value.x <= column.x + column.width) {
startIndex = i
}

if (me.containerWidth + value.x < column.x) {
endIndex = i - 1;
break
}
}
let me = this;

me.visibleColumns = [startIndex, endIndex]
if (value.x !== oldValue?.x && me.columnPositions.length > 0) {
me.updateVisibleColumns()
}

if (value.y !== oldValue?.y) {
Expand Down Expand Up @@ -792,6 +774,33 @@ class GridView extends Component {
me.update()
}
}

/**
*
*/
updateVisibleColumns() {
let me = this,
{x} = me.scrollPosition,
i = 0,
len = me.columnPositions.length,
endIndex = len - 1,
column, startIndex;

for (; i < len; i++) {
column = me.columnPositions[i];

if (x >= column.x && x <= column.x + column.width) {
startIndex = i
}

if (me.containerWidth + x < column.x) {
endIndex = i - 1;
break
}
}

me.visibleColumns = [startIndex, endIndex]
}
}

export default Neo.setupClass(GridView);

0 comments on commit 618ab2a

Please sign in to comment.