Home / Function/ _setScrollState() — react Function Reference

_setScrollState() — react Function Reference

Architecture documentation for the _setScrollState() function in VerticalScrollView.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  350965f1_fa72_4cdc_355c_903fbb465115["_setScrollState()"]
  15e8ee71_cd71_e6f6_40e5_59e8feb4985d["VerticalScrollView"]
  350965f1_fa72_4cdc_355c_903fbb465115 -->|defined in| 15e8ee71_cd71_e6f6_40e5_59e8feb4985d
  8864ee69_ae94_6428_b216_4158f39d66c2["setFrame()"]
  8864ee69_ae94_6428_b216_4158f39d66c2 -->|calls| 350965f1_fa72_4cdc_355c_903fbb465115
  dd08a669_02e3_2f36_98cb_b33b321d1071["scrollBy()"]
  dd08a669_02e3_2f36_98cb_b33b321d1071 -->|calls| 350965f1_fa72_4cdc_355c_903fbb465115
  91aaa6f8_9d0f_11f3_4d30_6f0b0e9b91b0["_handleMouseMove()"]
  91aaa6f8_9d0f_11f3_4d30_6f0b0e9b91b0 -->|calls| 350965f1_fa72_4cdc_355c_903fbb465115
  f077803e_adfb_e522_43d4_7b720fa272fa["clampState()"]
  350965f1_fa72_4cdc_355c_903fbb465115 -->|calls| f077803e_adfb_e522_43d4_7b720fa272fa
  7d8994ae_c610_bfe7_54d3_0ee2e2bf3ec1["areScrollStatesEqual()"]
  350965f1_fa72_4cdc_355c_903fbb465115 -->|calls| 7d8994ae_c610_bfe7_54d3_0ee2e2bf3ec1
  style 350965f1_fa72_4cdc_355c_903fbb465115 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-timeline/src/view-base/VerticalScrollView.js lines 265–296

  _setScrollState(proposedState: ScrollState): boolean {
    const contentHeight = this._contentView.frame.size.height;
    const containerHeight = this.frame.size.height;

    const clampedState = clampState({
      state: proposedState,
      minContentLength: contentHeight,
      maxContentLength: contentHeight,
      containerLength: containerHeight,
    });
    if (!areScrollStatesEqual(clampedState, this._scrollState)) {
      this._scrollState.offset = clampedState.offset;
      this._scrollState.length = clampedState.length;

      this.setNeedsDisplay();

      if (this._onChangeCallback !== null) {
        this._onChangeCallback(clampedState, this.frame.size.height);
      }

      return true;
    }

    // Don't allow wheel events to bubble past this view even if we've scrolled to the edge.
    // It just feels bad to have the scrolling jump unexpectedly from in a container to the outer page.
    // The only exception is when the container fits the content (no scrolling).
    if (contentHeight === containerHeight) {
      return false;
    }

    return true;
  }

Domain

Subdomains

Frequently Asked Questions

What does _setScrollState() do?
_setScrollState() is a function in the react codebase, defined in packages/react-devtools-timeline/src/view-base/VerticalScrollView.js.
Where is _setScrollState() defined?
_setScrollState() is defined in packages/react-devtools-timeline/src/view-base/VerticalScrollView.js at line 265.
What does _setScrollState() call?
_setScrollState() calls 2 function(s): areScrollStatesEqual, clampState.
What calls _setScrollState()?
_setScrollState() is called by 3 function(s): _handleMouseMove, scrollBy, setFrame.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free