mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-25 17:57:50 +01:00
re #123828. Reveal middle of the cell to the center.
This commit is contained in:
@@ -1252,8 +1252,20 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
|
||||
this.view.setScrollTop(this.view.elementTop(viewIndex));
|
||||
break;
|
||||
case CellRevealPosition.Center:
|
||||
this.view.setScrollTop(elementTop - this.view.renderHeight / 2);
|
||||
this.view.setScrollTop(this.view.elementTop(viewIndex) - this.view.renderHeight / 2);
|
||||
{
|
||||
// reveal the cell top in the viewport center initially
|
||||
this.view.setScrollTop(elementTop - this.view.renderHeight / 2);
|
||||
// cell rendered already, we now have a more accurate cell height
|
||||
const newElementTop = this.view.elementTop(viewIndex);
|
||||
const newElementHeight = this.view.elementHeight(viewIndex);
|
||||
const renderHeight = this.getViewScrollBottom() - this.getViewScrollTop();
|
||||
if (newElementHeight >= renderHeight) {
|
||||
// cell is larger than viewport, reveal top
|
||||
this.view.setScrollTop(newElementTop);
|
||||
} else {
|
||||
this.view.setScrollTop(newElementTop + (newElementHeight / 2) - (renderHeight / 2));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CellRevealPosition.Bottom:
|
||||
this.view.setScrollTop(this.scrollTop + (elementBottom - wrapperBottom));
|
||||
|
||||
Reference in New Issue
Block a user