Skip to main content

Reference

 

Applies only to Mobile Apps
OutSystems

View

Provides methods to deal with active view components and their state.

Summary

Methods
getCurrentScreenRootElement Returns the current screen DOM element. Used for class tweaks through DOM manipulation for animations.
registerDeviceClassGetter Register a function that provides a list of classes to apply to the document body. Expected classes to be returned are portrait or landscape — for orientation — and phone or tablet for device type. The method provided may emit other classes.
render Returns a Promise that will be resolved when the screen/block has been rendered with current model changes. Used to execute logic after the browser has rendered the current changes.
wasCurrentViewRestoredFromCache Checks if the current view state was restored from cache.

Methods

getCurrentScreenRootElement

getCurrentScreenRootElement(): Element

Returns the current screen DOM element. Used for class tweaks through DOM manipulation for animations.

Between transitions there are two screens (the one leaving and the one entering), and this function will return the entering screen.

Example:

// add custom class 'slide' to screen DOM element
$public.View.getCurrentScreenRootElement().classList.add("slide");

Returns

  • Element

registerDeviceClassGetter

registerDeviceClassGetter(getter: function): void

Register a function that provides a list of classes to apply to the document body. Expected classes to be returned are portrait or landscape — for orientation — and phone or tablet for device type. The method provided may emit other classes.

This method will be called upon whenever certain events, such as device orientation changes. All classes returned in previous calls will be removed before applying results of new calls.

Parameters

  • getterfunction

    Method that returns current orientation and device classes to apply.

    • (): string []

      Returns

      • string []

Returns

  • void

render

render(): Promise<void>

Returns a Promise that will be resolved when the screen/block has been rendered with current model changes. Used to execute logic after the browser has rendered the current changes.

Returns

  • Promise<void>

Promise resolved when the screen/block has been rendered with current model changes.

wasCurrentViewRestoredFromCache

wasCurrentViewRestoredFromCache(): boolean

Checks if the current view state was restored from cache.

Returns

  • boolean

Returns true when the current view state was restored from cache, or false otherwise.

  • Was this article helpful?