getPlatformDimensions

Updated:

Returns the platform's dimensions by default.

Description

Retrieves the platform's viewport dimensions. If there is a specific element on the platform that you would like the dimensions of, this capability also accepts an optional argument of a query selector. If provided, it will return the DomRect of that element if found. If no matching element is found, it will return a zeroed-out DomRect.

Signature

tecton.sources.getPlatformDimensions(selector?: string): Promise<PlatformDimensions | DomRect>;
export interface PlatformDimensions {
    scrollY: number;
    innerHeight: number;
    innerWidth: number;
    outletOffset?: number;
    top?: number;
    bottom?: number;
    orientationType?: string;
    orientationAngle?: number;
}
export interface DomRect {
    bottom: number;
    height: number;
    left: number;
    right: number;
    top: number;
    width: number;
    x: number;
    y: number;
    orientationType?: string;
    orientationAngle?: number;
}

Usage

Get overall platform dimensions.

tecton.sources.getPlatformDimensions().then(dimensions => {
    console.log(`The platform dimensions are ${dimensions}`);
});

Get dimensions of a specific element.

tecton.sources.getPlatformDimensions("#header").then(dimensions => {
    console.log(`The header dimensions are ${dimensions}`);
});

Parameters

selector

Platform Support

UUX
Config
Console

Frequently Asked Questions

There is 1 frequently asked question related to this page.

Changelog

The changelog provides a detailed history of new features, improvements, and bug fixes going back to Tecton 1.30.0. If the button is disabled, it indicates there have been no detectable changes since then.

Show changelog (3)