Skip to content

Commit 309915b

Browse files
authored
Nb Sticky Scroll z-index & css fixes (microsoft#201837)
* no absolute positioning, scrolltop compute based on sticky lines. * remove z-index var * compute re-write, remove init, reduce pop-in * dispose delayer * remove debounce * edge case for cell 0 header, next animation frame instead of debounce * add delayer back, further improve pop in * remove unused param, update testing snapshots
1 parent 969393c commit 309915b

9 files changed

+167
-234
lines changed

build/lib/stylelint/vscode-known-variables.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,6 @@
807807
"--z-index-notebook-progress-bar",
808808
"--z-index-notebook-scrollbar",
809809
"--z-index-run-button-container",
810-
"--z-index-notebook-sticky-scroll",
811810
"--zoom-factor",
812811
"--test-bar-width"
813812
]

src/vs/workbench/contrib/notebook/browser/media/notebookEditorStickyScroll.css

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
.monaco-workbench .notebookOverlay .notebook-sticky-scroll-container {
77
display: none;
8-
position: absolute;
98
background-color: var(--vscode-notebook-editorBackground);
10-
z-index: var(--z-index-notebook-sticky-scroll);
119
width: 100%;
1210
}
1311

@@ -17,7 +15,6 @@
1715
.notebook-sticky-scroll-line {
1816
background-color: var(--vscode-notebook-editorBackground);
1917
position: relative;
20-
z-index: 0;
2118
padding-left: 12px;
2219
/* transition: margin-top 0.2s ease-in-out; */
2320
}
@@ -35,15 +32,3 @@
3532
background-color: var(--vscode-editorStickyScrollHover-background);
3633
cursor: pointer;
3734
}
38-
39-
.monaco-workbench
40-
.notebookOverlay
41-
.notebook-sticky-scroll-container
42-
.notebook-shadow {
43-
display: block;
44-
top: 0;
45-
left: 3px;
46-
height: 3px;
47-
width: 100%;
48-
box-shadow: var(--vscode-scrollbar-shadow) 0 6px 6px -6px inset;
49-
}

src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,27 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
10701070

10711071
private _registerNotebookStickyScroll() {
10721072
this._notebookStickyScroll = this._register(this.instantiationService.createInstance(NotebookStickyScroll, this._notebookStickyScrollContainer, this, this._notebookOutline, this._list));
1073+
1074+
const localDisposableStore = this._register(new DisposableStore());
1075+
1076+
this._register(this._notebookStickyScroll.onDidChangeNotebookStickyScroll((sizeDelta) => {
1077+
const d = localDisposableStore.add(DOM.scheduleAtNextAnimationFrame(DOM.getWindow(this.getDomNode()), () => {
1078+
if (this.isDisposed) {
1079+
return;
1080+
}
1081+
1082+
if (this._dimension) {
1083+
if (sizeDelta > 0) { // delta > 0 ==> sticky is growing, cell list shrinking
1084+
this.layout(this._dimension);
1085+
this.setScrollTop(this.scrollTop + sizeDelta);
1086+
} else if (sizeDelta < 0) { // delta < 0 ==> sticky is shrinking, cell list growing
1087+
this.setScrollTop(this.scrollTop + sizeDelta);
1088+
this.layout(this._dimension);
1089+
}
1090+
}
1091+
localDisposableStore.delete(d);
1092+
}));
1093+
}));
10731094
}
10741095

10751096
private _updateOutputRenderers() {
@@ -1823,7 +1844,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
18231844

18241845
this._dimension = dimension;
18251846
this._position = position;
1826-
const newBodyHeight = this.getBodyHeight(dimension.height);
1847+
const newBodyHeight = this.getBodyHeight(dimension.height) - this.getLayoutInfo().stickyHeight;
18271848
DOM.size(this._body, dimension.width, newBodyHeight);
18281849

18291850
const topInserToolbarHeight = this._notebookOptions.computeTopInsertToolbarHeight(this.viewModel?.viewType);
@@ -3152,7 +3173,6 @@ registerZIndex(ZIndex.Base, 28, 'notebook-cell-bottom-toolbar-container');
31523173
registerZIndex(ZIndex.Base, 29, 'notebook-run-button-container');
31533174
registerZIndex(ZIndex.Base, 29, 'notebook-input-collapse-condicon');
31543175
registerZIndex(ZIndex.Base, 30, 'notebook-cell-output-toolbar');
3155-
registerZIndex(ZIndex.Base, 31, 'notebook-sticky-scroll');
31563176
registerZIndex(ZIndex.Sash, 1, 'notebook-cell-expand-part-button');
31573177
registerZIndex(ZIndex.Sash, 2, 'notebook-cell-toolbar');
31583178
registerZIndex(ZIndex.Sash, 3, 'notebook-cell-toolbar-dropdown-active');

src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbarStickyScroll.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ export function registerCellToolbarStickyScroll(notebookEditor: INotebookEditor,
1515
if (cell.isInputCollapsed) {
1616
element.style.top = '';
1717
} else {
18-
const stickyHeight = notebookEditor.getLayoutInfo().stickyHeight;
1918
const scrollTop = notebookEditor.scrollTop;
2019
const elementTop = notebookEditor.getAbsoluteTopOfElement(cell);
21-
const diff = scrollTop - elementTop + extraOffset + stickyHeight;
20+
const diff = scrollTop - elementTop + extraOffset;
2221
const maxTop = cell.layoutInfo.editorHeight + cell.layoutInfo.statusBarHeight - 45; // subtract roughly the height of the execution order label plus padding
2322
const top = maxTop > 20 ? // Don't move the run button if it can only move a very short distance
2423
clamp(min, diff, maxTop) :

0 commit comments

Comments
 (0)