Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SplittableScreen<SS>

SplittableScreen represents a preview screen and renders all regions contained within that screen. This type of screen is intended to be used inside the LayoutDesigner component and allows the user to segment the screen into regions by splitting existing regions. For this purpose, it has callbacks for splitting an existing region or undoing the most recent split for whenever such an event is triggered. The screen information is passed in through the screenInfo prop. The screen can render at an different sizes, determined by the prop width. Height is then calculated corresponding to that.

param

An object containing data associated with a preview screen

param

The width of the rendered screen

param

Callback triggered when the user selects the option to remove the screen

param

Callback triggered when the user splits a region

param

Callback triggered when the user undoes the last split

Type parameters

  • SS

Hierarchy

Index

Constructors

constructor

Properties

context

context: any

props

props: Readonly<object> & Readonly<SplittableScreenProps>

refs

refs: object

Type declaration

  • [key: string]: ReactInstance

state

state: Readonly<SplittableScreenState>

Methods

Optional UNSAFE_componentWillMount

  • UNSAFE_componentWillMount(): void

Optional UNSAFE_componentWillReceiveProps

Optional UNSAFE_componentWillUpdate

Optional componentDidCatch

  • componentDidCatch(error: Error, errorInfo: ErrorInfo): void
  • Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.

    Parameters

    • error: Error
    • errorInfo: ErrorInfo

    Returns void

Optional componentDidMount

  • componentDidMount(): void
  • Called immediately after a compoment is mounted. Setting state here will trigger re-rendering.

    Returns void

Optional componentDidUpdate

  • Called immediately after updating occurs. Not called for the initial render.

    The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.

    Parameters

    Returns void

Optional componentWillMount

  • componentWillMount(): void

Optional componentWillReceiveProps

Optional componentWillUnmount

  • componentWillUnmount(): void
  • Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as cancelled network requests, or cleaning up any DOM elements created in componentDidMount.

    Returns void

Optional componentWillUpdate

forceUpdate

  • forceUpdate(callBack?: undefined | function): void
  • Parameters

    • Optional callBack: undefined | function

    Returns void

Private getClickedRegion

  • getClickedRegion(x: number, y: number): ScreenRegion | undefined
  • Returns the topmost screen region which contains the coordinates given by x and y, or undefined if the coordinates are outside screen bounds.

    Parameters

    • x: number

      X coordinate of the click event

    • y: number

      Y coordinate of the click event

    Returns ScreenRegion | undefined

Optional getSnapshotBeforeUpdate

  • Runs before React applies the result of render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before render causes changes to it.

    Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated lifecycle events from running.

    Parameters

    Returns SS | null

Private handleCanvasClick

  • handleCanvasClick(ev: MouseEvent, x: number, y: number): void
  • Callback invoked when the user clicks on a screen region. Receives the original mouse event that was fired as well as the coordinates the user clicked at relative to the top-left corner of the canvas.

    Parameters

    • ev: MouseEvent

      Original mouse event object

    • x: number

      X coordinate relative to the top-left corner of the canvas

    • y: number

      Y coordinate relative to the top-left corner of the canvas

    Returns void

render

  • render(): Element
  • Renders the component

    Returns Element

setState

  • setState<K>(state: function | null | S | object, callback?: undefined | function): void
  • Type parameters

    • K: keyof SplittableScreenState

    Parameters

    • state: function | null | S | object
    • Optional callback: undefined | function

    Returns void

Optional shouldComponentUpdate

  • Called to determine whether the change in props and state should trigger a re-render.

    Component always returns true. PureComponent implements a shallow comparison on props and state and returns true if any props or states have changed.

    If false is returned, Component#render, componentWillUpdate and componentDidUpdate will not be called.

    Parameters

    Returns boolean

Private splitRegion

  • splitRegion(orientation: "horizontal" | "vertical"): void
  • Splits the current region either horizontally or vertically, thus creating two new sub-regions. The old region will be destroyed in the process. The split position is determined by the [x, y] coordinates found in state.

    Parameters

    • orientation: "horizontal" | "vertical"

      Orientation of the split. Either horizontal or vertical

    Returns void

Generated using TypeDoc