Home / Class/ HorizontalPanAndZoomView Class — react Architecture

HorizontalPanAndZoomView Class — react Architecture

Architecture documentation for the HorizontalPanAndZoomView class in HorizontalPanAndZoomView.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d["HorizontalPanAndZoomView"]
  651fe3e5_90b9_93e1_39f6_c335dae25ac7["HorizontalPanAndZoomView.js"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|defined in| 651fe3e5_90b9_93e1_39f6_c335dae25ac7
  480f5b5e_d754_4ab1_da57_71bc19357caf["constructor()"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|method| 480f5b5e_d754_4ab1_da57_71bc19357caf
  a56c87e4_5abf_4094_4e1a_cc6225040263["setScrollState()"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|method| a56c87e4_5abf_4094_4e1a_cc6225040263
  3fecd1d6_3b0e_08d7_18fe_cef444b6228a["zoomToRange()"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|method| 3fecd1d6_3b0e_08d7_18fe_cef444b6228a
  9297afce_5400_b859_5a10_f796001f1ef9["desiredSize()"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|method| 9297afce_5400_b859_5a10_f796001f1ef9
  7bceb63d_e298_b3cf_fd4b_0588920f652c["layoutSubviews()"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|method| 7bceb63d_e298_b3cf_fd4b_0588920f652c
  6153f3f9_e7cd_ad34_9d0a_89b5424a4b64["handleInteraction()"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|method| 6153f3f9_e7cd_ad34_9d0a_89b5424a4b64
  05ae85d4_9003_2adf_73c8_cf23fd4a009f["_handleMouseDown()"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|method| 05ae85d4_9003_2adf_73c8_cf23fd4a009f
  34d782a2_e7cd_4614_a385_810a1041f544["_handleMouseMove()"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|method| 34d782a2_e7cd_4614_a385_810a1041f544
  1ed652d5_87a5_0997_e169_967fb6ccaba6["_handleMouseUp()"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|method| 1ed652d5_87a5_0997_e169_967fb6ccaba6
  fd7bd265_3613_50c6_41d6_401ef40af331["_handleWheel()"]
  286a732c_79f8_d4a2_284e_8f3ea43c6d7d -->|method| fd7bd265_3613_50c6_41d6_401ef40af331

Relationship Graph

Source Code

packages/react-devtools-timeline/src/view-base/HorizontalPanAndZoomView.js lines 39–245

export class HorizontalPanAndZoomView extends View {
  _contentView: View;
  _intrinsicContentWidth: number;
  _isPanning: boolean = false;
  _viewState: ViewState;

  constructor(
    surface: Surface,
    frame: Rect,
    contentView: View,
    intrinsicContentWidth: number,
    viewState: ViewState,
  ) {
    super(surface, frame);

    this._contentView = contentView;
    this._intrinsicContentWidth = intrinsicContentWidth;
    this._viewState = viewState;

    viewState.onHorizontalScrollStateChange(scrollState => {
      this.zoomToRange(scrollState.offset, scrollState.length);
    });

    this.addSubview(contentView);
  }

  /**
   * Just sets scroll state.
   * Use `_setStateAndInformCallbacksIfChanged` if this view's callbacks should also be called.
   *
   * @returns Whether state was changed
   * @private
   */
  setScrollState(proposedState: ScrollState) {
    const clampedState = clampState({
      state: proposedState,
      minContentLength: this._intrinsicContentWidth * MIN_ZOOM_LEVEL,
      maxContentLength: this._intrinsicContentWidth * MAX_ZOOM_LEVEL,
      containerLength: this.frame.size.width,
    });
    if (
      !areScrollStatesEqual(clampedState, this._viewState.horizontalScrollState)
    ) {
      this.setNeedsDisplay();
    }
  }

  /**
   * Zoom to a specific range of the content specified as a range of the
   * content view's intrinsic content size.
   *
   * Does not inform callbacks of state change since this is a public API.
   */
  zoomToRange(rangeStart: number, rangeEnd: number) {
    const newState = moveStateToRange({
      state: this._viewState.horizontalScrollState,
      rangeStart,
      rangeEnd,
      contentLength: this._intrinsicContentWidth,

      minContentLength: this._intrinsicContentWidth * MIN_ZOOM_LEVEL,
      maxContentLength: this._intrinsicContentWidth * MAX_ZOOM_LEVEL,
      containerLength: this.frame.size.width,
    });
    this.setScrollState(newState);
  }

  desiredSize(): Size | IntrinsicSize {
    return this._contentView.desiredSize();
  }

  layoutSubviews() {
    const {offset, length} = this._viewState.horizontalScrollState;
    const proposedFrame = {
      origin: {
        x: this.frame.origin.x + offset,
        y: this.frame.origin.y,
      },
      size: {
        width: length,
        height: this.frame.size.height,

Domain

Frequently Asked Questions

What is the HorizontalPanAndZoomView class?
HorizontalPanAndZoomView is a class in the react codebase, defined in packages/react-devtools-timeline/src/view-base/HorizontalPanAndZoomView.js.
Where is HorizontalPanAndZoomView defined?
HorizontalPanAndZoomView is defined in packages/react-devtools-timeline/src/view-base/HorizontalPanAndZoomView.js at line 39.

Analyze Your Own Codebase

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

Try Supermodel Free