Skip to content

Commit

Permalink
Fix scrolling to a match in the grid search.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Feb 4, 2019
1 parent 6a04da9 commit 53fe3d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
20 changes: 10 additions & 10 deletions packages/csvviewer/src/widget.ts
Expand Up @@ -125,12 +125,12 @@ export class GridSearchService {
const minColumn = this._grid.scrollX / this._grid.baseColumnSize;
const maxColumn =
(this._grid.scrollX + this._grid.pageWidth) / this._grid.baseColumnSize;
const isMatchInViewport = () => {
const isInViewport = (row: number, column: number) => {
return (
this._row >= minRow &&
this._row <= maxRow &&
this._column >= minColumn &&
this._column <= maxColumn
row >= minRow &&
row <= maxRow &&
column >= minColumn &&
column <= maxColumn
);
};

Expand All @@ -154,15 +154,15 @@ export class GridSearchService {
// cell rects, not the entire grid.
this._grid.repaint();

if (!isMatchInViewport()) {
if (!isInViewport(row, col)) {
// scroll the matching cell into view
let scrollX = this._grid.scrollX;
let scrollY = this._grid.scrollY;
let scrollX = 0;
let scrollY = 0;
/* see also https://github.com/jupyterlab/jupyterlab/pull/5523#issuecomment-432621391 */
for (let i = scrollY; i < row - 1; i++) {
for (let i = 0; i < row - 1; i++) {
scrollY += this._grid.sectionSize('row', i);
}
for (let j = scrollX; j < col - 1; j++) {
for (let j = 0; j < col - 1; j++) {
scrollX += this._grid.sectionSize('column', j);
}
this._grid.scrollTo(scrollX, scrollY);
Expand Down
4 changes: 1 addition & 3 deletions packages/documentsearch/tsconfig.json
Expand Up @@ -4,9 +4,7 @@
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/**/*"
],
"include": ["src/**/*"],
"references": [
{
"path": "../apputils"
Expand Down

0 comments on commit 53fe3d4

Please sign in to comment.