Skip to content

Commit 380d3d6

Browse files
committed
Don't show shadow if it's not scrolled
1 parent 4028004 commit 380d3d6

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/vscode-scrollable/vscode-scrollable.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class VscodeScrollable extends VscElement {
2929

3030
@property({type: Number, attribute: 'scroll-pos'})
3131
set scrollPos(val: number) {
32-
this._scrollPos = val;
32+
this._scrollPos = this._limitScrollPos(val);
3333
this._updateThumbPosition();
3434
this.requestUpdate();
3535
}
@@ -129,6 +129,21 @@ export class VscodeScrollable extends VscElement {
129129
this._updateScrollbar();
130130
};
131131

132+
private _limitScrollPos(pos: number) {
133+
const minValue = 0;
134+
let maxValue: number;
135+
136+
if (this?.offsetHeight ?? 0 >= (this._contentElement?.offsetHeight ?? 0)) {
137+
maxValue = 0;
138+
} else {
139+
maxValue = Math.max(0, this.offsetHeight - this._thumbHeight);
140+
}
141+
142+
console.log(minValue, maxValue);
143+
144+
return Math.max(minValue, Math.min(maxValue, pos));
145+
}
146+
132147
private _updateScrollbar() {
133148
const contentHeight = this._contentElement.offsetHeight;
134149
const componentHeight = this.offsetHeight;

0 commit comments

Comments
 (0)