VerticalScrollView Class — react Architecture
Architecture documentation for the VerticalScrollView class in VerticalScrollView.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 15e8ee71_cd71_e6f6_40e5_59e8feb4985d["VerticalScrollView"] be7fceed_f363_2288_8ab1_9e46ccc7de65["VerticalScrollView.js"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|defined in| be7fceed_f363_2288_8ab1_9e46ccc7de65 37f0fa7a_a424_f502_b9ca_72177675b329["constructor()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| 37f0fa7a_a424_f502_b9ca_72177675b329 8864ee69_ae94_6428_b216_4158f39d66c2["setFrame()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| 8864ee69_ae94_6428_b216_4158f39d66c2 6bb2400d_04ee_af63_1d65_f8d70d7f4857["desiredSize()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| 6bb2400d_04ee_af63_1d65_f8d70d7f4857 45da1002_daee_6aef_1de9_74eac3a50c0e["draw()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| 45da1002_daee_6aef_1de9_74eac3a50c0e 21742aca_6c3f_da0b_7ed0_8cec93753d4d["layoutSubviews()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| 21742aca_6c3f_da0b_7ed0_8cec93753d4d eb1765a3_0863_dd2c_a927_6e4f28217907["handleInteraction()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| eb1765a3_0863_dd2c_a927_6e4f28217907 4ef6a5e7_70e0_d9c3_fb33_e11b123f2e96["onChange()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| 4ef6a5e7_70e0_d9c3_fb33_e11b123f2e96 dd08a669_02e3_2f36_98cb_b33b321d1071["scrollBy()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| dd08a669_02e3_2f36_98cb_b33b321d1071 07384155_fd65_ab4d_a83c_269ccec4232c["_handleMouseDown()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| 07384155_fd65_ab4d_a83c_269ccec4232c 91aaa6f8_9d0f_11f3_4d30_6f0b0e9b91b0["_handleMouseMove()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| 91aaa6f8_9d0f_11f3_4d30_6f0b0e9b91b0 f1e0324e_36bb_6810_d53a_763330b48e66["_handleMouseUp()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| f1e0324e_36bb_6810_d53a_763330b48e66 c53bd458_8fdb_18ff_350b_512cb76d863c["_handleWheelShift()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| c53bd458_8fdb_18ff_350b_512cb76d863c fab01b1f_059e_02e3_e192_f5ea56188371["_restoreMutableViewState()"] 15e8ee71_cd71_e6f6_40e5_59e8feb4985d -->|method| fab01b1f_059e_02e3_e192_f5ea56188371
Relationship Graph
Source Code
packages/react-devtools-timeline/src/view-base/VerticalScrollView.js lines 42–297
export class VerticalScrollView extends View {
_contentView: View;
_isPanning: boolean;
_mutableViewStateKey: string;
_onChangeCallback: OnChangeCallback | null;
_scrollState: ScrollState;
_viewState: ViewState;
constructor(
surface: Surface,
frame: Rect,
contentView: View,
viewState: ViewState,
label: string,
) {
super(surface, frame);
this._contentView = contentView;
this._isPanning = false;
this._mutableViewStateKey = label + ':VerticalScrollView';
this._onChangeCallback = null;
this._scrollState = {
offset: 0,
length: 0,
};
this._viewState = viewState;
this.addSubview(contentView);
this._restoreMutableViewState();
}
setFrame(newFrame: Rect) {
super.setFrame(newFrame);
// Revalidate scrollState
this._setScrollState(this._scrollState);
}
desiredSize(): Size | IntrinsicSize {
return this._contentView.desiredSize();
}
draw(context: CanvasRenderingContext2D, viewRefs: ViewRefs) {
super.draw(context, viewRefs);
// Show carets if there's scroll overflow above or below the viewable area.
if (this.frame.size.height > CARET_HEIGHT * 2 + CARET_MARGIN * 3) {
const offset = this._scrollState.offset;
const desiredSize = this._contentView.desiredSize();
const above = offset;
const below = this.frame.size.height - desiredSize.height - offset;
if (above < 0 || below < 0) {
const {visibleArea} = this;
const {x, y} = visibleArea.origin;
const {width, height} = visibleArea.size;
const horizontalCenter = x + width / 2;
const halfWidth = CARET_WIDTH;
const left = horizontalCenter + halfWidth;
const right = horizontalCenter - halfWidth;
if (above < 0) {
const topY = y + CARET_MARGIN;
context.beginPath();
context.moveTo(horizontalCenter, topY);
context.lineTo(left, topY + CARET_HEIGHT);
context.lineTo(right, topY + CARET_HEIGHT);
context.closePath();
context.fillStyle = COLORS.SCROLL_CARET;
context.fill();
}
if (below < 0) {
const bottomY = y + height - CARET_MARGIN;
context.beginPath();
context.moveTo(horizontalCenter, bottomY);
Domain
Source
Frequently Asked Questions
What is the VerticalScrollView class?
VerticalScrollView is a class in the react codebase, defined in packages/react-devtools-timeline/src/view-base/VerticalScrollView.js.
Where is VerticalScrollView defined?
VerticalScrollView is defined in packages/react-devtools-timeline/src/view-base/VerticalScrollView.js at line 42.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free