Allows web content displayed in a <sci-router-outlet> to define its preferred size.

The preferred size of an element is the minimum size that will allow it to display normally. Setting a preferred size is useful if the outlet is displayed in a layout that aligns its items based on the items's content size.

When setting a preferred size, the outlet containing this microfrontend will adapt its size to the reported preferred size.

Hierarchy

  • PreferredSizeService

Implements

  • PreDestroy

Constructors

Methods

  • Determines the preferred size from the given element's dimension and reports it to the router outlet embedding this web content. As the value for the preferred size, the offset-width and offset-height of the element are used, which is the total amount of space the element occupies, including the width of the visible content, scrollbars (if any), padding, and border.

    When the size of the element changes, the changed size is reported to the outlet, which then adaps its size accordingly. To stop the notifying of the preferred size to the outlet, pass undefined as the value, which also unsets the preferred size.

    If the element is removed from the DOM, the preferred size is reset and reporting suspended until it is attached again. If a new element is set as dimension observer, then the previous one is unsubscribed.

    Prerequisites

    • The element to be observed must behave as block-level box and not as inline-level box. So, if you want to observe an inline element, set its display type to either block or inline-block.
    • If the element to be observed should not fill the remaining space and may change in size, we recommend taking it out of the document element flow, i.e., position it absolutely without defining a width and height. Otherwise, once the element has reported a preferred size, it could not shrink below that size.

    Parameters

    • element: undefined | HTMLElement

      The element of which the preferred size is to be observed and used as the outlet's size.

    Returns void

Generated using TypeDoc