Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nb Sticky Scroll z-index & css fixes #201837

Merged
merged 8 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build/lib/stylelint/vscode-known-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,6 @@
"--z-index-notebook-progress-bar",
"--z-index-notebook-scrollbar",
"--z-index-run-button-container",
"--z-index-notebook-sticky-scroll",
"--zoom-factor",
"--test-bar-width"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@

.monaco-workbench .notebookOverlay .notebook-sticky-scroll-container {
display: none;
position: absolute;
background-color: var(--vscode-notebook-editorBackground);
z-index: var(--z-index-notebook-sticky-scroll);
width: 100%;
font-family: var(--notebook-cell-input-preview-font-family);
}

.monaco-workbench
.notebookOverlay
.notebook-sticky-scroll-container
.notebook-sticky-scroll-line {
background-color: var(--vscode-notebook-editorBackground);
position: relative;
z-index: 0;
padding-left: 12px;
/* transition: margin-top 0.2s ease-in-out; */
}
Expand All @@ -35,15 +32,3 @@
background-color: var(--vscode-editorStickyScrollHover-background);
cursor: pointer;
}

.monaco-workbench
.notebookOverlay
.notebook-sticky-scroll-container
.notebook-shadow {
display: block;
top: 0;
left: 3px;
height: 3px;
width: 100%;
box-shadow: var(--vscode-scrollbar-shadow) 0 6px 6px -6px inset;
}
15 changes: 13 additions & 2 deletions src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,18 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD

private _registerNotebookStickyScroll() {
this._notebookStickyScroll = this._register(this.instantiationService.createInstance(NotebookStickyScroll, this._notebookStickyScrollContainer, this, this._notebookOutline, this._list));

this._register(this._notebookStickyScroll.onDidChangeNotebookStickyScroll((sizeDelta) => {
if (this._dimension) { // TODO @Yoyokrazy: think this logic is unnecessary in this situation
if (sizeDelta > 0) { // delta > 0 ==> sticky is growing, cell list shrinking
this.layout(this._dimension);
this.setScrollTop(this.scrollTop + sizeDelta);
} else if (sizeDelta < 0) { // delta < 0 ==> sticky is shrinking, cell list growing
this.setScrollTop(this.scrollTop + sizeDelta);
this.layout(this._dimension);
}
}
}));
}

private _updateOutputRenderers() {
Expand Down Expand Up @@ -1818,7 +1830,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD

this._dimension = dimension;
this._position = position;
const newBodyHeight = this.getBodyHeight(dimension.height);
const newBodyHeight = this.getBodyHeight(dimension.height) - this.getLayoutInfo().stickyHeight;
DOM.size(this._body, dimension.width, newBodyHeight);

const topInserToolbarHeight = this._notebookOptions.computeTopInsertToolbarHeight(this.viewModel?.viewType);
Expand Down Expand Up @@ -3142,7 +3154,6 @@ registerZIndex(ZIndex.Base, 28, 'notebook-cell-bottom-toolbar-container');
registerZIndex(ZIndex.Base, 29, 'notebook-run-button-container');
registerZIndex(ZIndex.Base, 29, 'notebook-input-collapse-condicon');
registerZIndex(ZIndex.Base, 30, 'notebook-cell-output-toolbar');
registerZIndex(ZIndex.Base, 31, 'notebook-sticky-scroll');
registerZIndex(ZIndex.Sash, 1, 'notebook-cell-expand-part-button');
registerZIndex(ZIndex.Sash, 2, 'notebook-cell-toolbar');
registerZIndex(ZIndex.Sash, 3, 'notebook-cell-toolbar-dropdown-active');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ export function registerCellToolbarStickyScroll(notebookEditor: INotebookEditor,
if (cell.isInputCollapsed) {
element.style.top = '';
} else {
const stickyHeight = notebookEditor.getLayoutInfo().stickyHeight;
const scrollTop = notebookEditor.scrollTop;
const elementTop = notebookEditor.getAbsoluteTopOfElement(cell);
const diff = scrollTop - elementTop + extraOffset + stickyHeight;
const diff = scrollTop - elementTop + extraOffset;
const maxTop = cell.layoutInfo.editorHeight + cell.layoutInfo.statusBarHeight - 45; // subtract roughly the height of the execution order label plus padding
const top = maxTop > 20 ? // Don't move the run button if it can only move a very short distance
clamp(min, diff, maxTop) :
Expand Down
Loading
Loading