Docs (4.0.0)
Viewport context

interface ViewportContext

Interface definition for an object that contains information about the user’s viewport, e.g. browser window.

interface ViewportContext
extends ManagedObject

Description

A ViewportContext object is available on the global application context, as app.viewport. This instance can be used to customize the UI for different viewport sizes — either directly or through a binding.

Examples

// Determine the viewport size directly:
if (app.viewport.portrait) {
  // ...do something specific here
}
// Bind to viewport properties from a JSX view:
<conditional state={bound("viewport.wide")}>
  // ...view for wide viewports
</conditional>

Constructor

Instance Members

  • widthThe viewport width in logical pixel units.
  • heightThe viewport height in logical pixel units.
  • portraitTrue if the viewport is taller than it is wide.
  • narrowTrue if the viewport width is below the first breakpoint.
  • wideTrue if the viewport width exceeds the second breakpoint.
  • shortTrue if the viewport height is below the first breakpoint.
  • tallTrue if the viewport height exceeds the second breakpoint.
  • setBreakpoints(small, large)Updates breakpoints for narrow, wide, short and tall properties.

Inherited Members