Skip to content

Commit 64eb933

Browse files
authored
Fixed scrolling not being set properly by filters (#386)
* Fixed scrolling not being set properly by filters * v1.8.4
1 parent 6b7be4d commit 64eb933

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

packages/cheetah-grid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cheetah-grid",
3-
"version": "1.8.3",
3+
"version": "1.8.4",
44
"description": "Cheetah Grid is a high performance grid engine that works on canvas",
55
"keywords": [
66
"spreadsheet",

packages/cheetah-grid/src/js/core/DrawGrid.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3229,8 +3229,8 @@ export abstract class DrawGrid extends EventTarget implements DrawGridAPI {
32293229
canvas.style.width = `${width}px`;
32303230
canvas.style.height = `${height}px`;
32313231

3232-
const sel = this[_].selection.select;
3233-
this[_].focusControl.setFocusRect(this.getCellRect(sel.col, sel.row));
3232+
const { focus } = this[_].selection;
3233+
this[_].focusControl.setFocusRect(this.getCellRect(focus.col, focus.row));
32343234
}
32353235
/**
32363236
* Apply the changed scroll size.
@@ -3251,6 +3251,9 @@ export abstract class DrawGrid extends EventTarget implements DrawGridAPI {
32513251
left: scrollable.scrollLeft,
32523252
top: scrollable.scrollTop,
32533253
};
3254+
3255+
const { focus } = this[_].selection;
3256+
this[_].focusControl.setFocusRect(this.getCellRect(focus.col, focus.row));
32543257
return true;
32553258
}
32563259
/**

packages/cheetah-grid/src/js/data/FilterDataSource.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class FilterData<T> {
5959
_owner: FilterDataSource<T>;
6060
_dataSourceItr: DataSourceIterator<T>;
6161
_filter: Filter<T>;
62-
_filterdList: (T | undefined)[];
62+
_filteredList: (T | undefined)[];
6363
_queues: (Promise<T | undefined> | null)[];
6464
_cancel = false;
6565
constructor(
@@ -70,16 +70,16 @@ class FilterData<T> {
7070
this._owner = dc;
7171
this._dataSourceItr = new DataSourceIterator(original);
7272
this._filter = filter;
73-
this._filterdList = [];
73+
this._filteredList = [];
7474
this._queues = [];
7575
}
7676
get(index: number): MaybePromiseOrUndef<T> {
7777
if (this._cancel) {
7878
return undefined;
7979
}
80-
const filterdList = this._filterdList;
81-
if (index < filterdList.length) {
82-
return filterdList[index];
80+
const filteredList = this._filteredList;
81+
if (index < filteredList.length) {
82+
return filteredList[index];
8383
}
8484
const queues = this._queues;
8585
const indexQueue = queues[index];
@@ -110,7 +110,7 @@ class FilterData<T> {
110110
index: number,
111111
testTimeout: () => boolean
112112
): MaybePromiseOrUndef<T> {
113-
const filterdList = this._filterdList;
113+
const filteredList = this._filteredList;
114114
const filter = this._filter;
115115
const dataSourceItr = this._dataSourceItr;
116116

@@ -131,9 +131,9 @@ class FilterData<T> {
131131
return queue;
132132
}
133133
if (filter(record)) {
134-
filterdList.push(record);
135-
if (index < filterdList.length) {
136-
return filterdList[index];
134+
filteredList.push(record);
135+
if (index < filteredList.length) {
136+
return filteredList[index];
137137
}
138138
}
139139
if (testTimeout()) {
@@ -151,7 +151,7 @@ class FilterData<T> {
151151
}
152152
}
153153
const dc = this._owner;
154-
dc.length = filterdList.length;
154+
dc.length = filteredList.length;
155155
return undefined;
156156
}
157157
}

packages/cheetah-grid/src/js/internal/Scrollable.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ export class Scrollable {
7777
}
7878
private _update(): void {
7979
let domHeight;
80+
const { offsetHeight, offsetWidth } = this._scrollable;
8081
if (this._height > MAX_SCROLL) {
8182
const sbSize = style.getScrollBarSize();
82-
const { offsetHeight } = this._scrollable;
8383
const vScrollRange = MAX_SCROLL - offsetHeight + sbSize;
8484
const rScrollRange = this._height - offsetHeight + sbSize;
8585
this._p = vScrollRange / rScrollRange;
@@ -91,5 +91,14 @@ export class Scrollable {
9191

9292
this._endPointElement.style.top = `${domHeight.toFixed()}px`;
9393
this._endPointElement.style.left = `${this._width.toFixed()}px`;
94+
95+
// Sets the maximum value to the scroll position
96+
// if the current scroll position exceeds the maximum value.
97+
if (this.scrollTop > this.scrollHeight - offsetHeight) {
98+
this.scrollTop = this.scrollHeight - offsetHeight;
99+
}
100+
if (this.scrollLeft > this.scrollWidth - offsetWidth) {
101+
this.scrollLeft = this.scrollWidth - offsetWidth;
102+
}
94103
}
95104
}

packages/vue-cheetah-grid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cheetah-grid",
3-
"version": "1.8.3",
3+
"version": "1.8.4",
44
"description": "Cheetah Grid for Vue.js",
55
"main": "lib/index.js",
66
"unpkg": "dist/vueCheetahGrid.js",

0 commit comments

Comments
 (0)