VerticalScrollBarView Class — react Architecture
Architecture documentation for the VerticalScrollBarView class in VerticalScrollBarView.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 61a52b70_028c_d7b7_0542_1547d92cd850["VerticalScrollBarView"] 4a10df0d_a8e2_1549_3912_4d2e6db4d890["VerticalScrollBarView.js"] 61a52b70_028c_d7b7_0542_1547d92cd850 -->|defined in| 4a10df0d_a8e2_1549_3912_4d2e6db4d890 b0f106a1_bb84_aee5_9341_31d5c96a7c75["constructor()"] 61a52b70_028c_d7b7_0542_1547d92cd850 -->|method| b0f106a1_bb84_aee5_9341_31d5c96a7c75 78ba298b_e950_e359_1bc4_641a17c0f775["desiredSize()"] 61a52b70_028c_d7b7_0542_1547d92cd850 -->|method| 78ba298b_e950_e359_1bc4_641a17c0f775
Relationship Graph
Source Code
packages/react-devtools-timeline/src/view-base/vertical-scroll-overflow/VerticalScrollBarView.js lines 38–219
export class VerticalScrollBarView extends View {
_contentHeight: number = 0;
_isScrolling: boolean = false;
_scrollBarRect: Rect = HIDDEN_RECT;
_scrollThumbRect: Rect = HIDDEN_RECT;
_verticalScrollOverflowView: VerticalScrollOverflowView;
constructor(
surface: Surface,
frame: Rect,
verticalScrollOverflowView: VerticalScrollOverflowView,
) {
super(surface, frame);
this._verticalScrollOverflowView = verticalScrollOverflowView;
}
desiredSize(): {+height: number, +width: number} {
return {
width: SCROLL_BAR_SIZE,
height: 0, // No desired height
};
}
getMaxScrollThumbY(): number {
const {height} = this.frame.size;
const maxScrollThumbY = height - this._scrollThumbRect.size.height;
return maxScrollThumbY;
}
setContentHeight(contentHeight: number) {
this._contentHeight = contentHeight;
const {height, width} = this.frame.size;
const proposedScrollThumbRect = {
origin: {
x: this.frame.origin.x,
y: this._scrollThumbRect.origin.y,
},
size: {
width,
height: height * (height / contentHeight),
},
};
if (!rectEqualToRect(this._scrollThumbRect, proposedScrollThumbRect)) {
this._scrollThumbRect = proposedScrollThumbRect;
this.setNeedsDisplay();
}
}
setScrollThumbY(value: number) {
const {height} = this.frame.size;
const maxScrollThumbY = this.getMaxScrollThumbY();
const newScrollThumbY = Math.max(0, Math.min(maxScrollThumbY, value));
this._scrollThumbRect = {
...this._scrollThumbRect,
origin: {
x: this.frame.origin.x,
y: newScrollThumbY,
},
};
const maxContentOffset = this._contentHeight - height;
const contentScrollOffset =
(newScrollThumbY / maxScrollThumbY) * maxContentOffset * -1;
this._verticalScrollOverflowView.setScrollOffset(
contentScrollOffset,
maxScrollThumbY,
);
}
draw(context: CanvasRenderingContext2D, viewRefs: ViewRefs) {
const {x, y} = this.frame.origin;
const {width, height} = this.frame.size;
Domain
Defined In
Source
Frequently Asked Questions
What is the VerticalScrollBarView class?
VerticalScrollBarView is a class in the react codebase, defined in packages/react-devtools-timeline/src/view-base/vertical-scroll-overflow/VerticalScrollBarView.js.
Where is VerticalScrollBarView defined?
VerticalScrollBarView is defined in packages/react-devtools-timeline/src/view-base/vertical-scroll-overflow/VerticalScrollBarView.js at line 38.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free