Join us online - 19th of November
Save your spot
For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.

Interface ScreenOrientation

The ScreenOrientation interface of the Screen Orientation API provides information about the current orientation of the document.

MDN Reference

interface ScreenOrientation {
    angle: number;
    onchange: ((this: ScreenOrientation, ev: Event) => any) | null;
    type: OrientationType;
    addEventListener<K extends "change">(
        type: K,
        listener: (
            this: ScreenOrientation,
            ev: ScreenOrientationEventMap[K],
        ) => any,
        options?: boolean | AddEventListenerOptions,
    ): void;
    addEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | AddEventListenerOptions,
    ): void;
    dispatchEvent(event: Event): boolean;
    lock(orientation: OrientationLockType): Promise<void>;
    removeEventListener<K extends "change">(
        type: K,
        listener: (
            this: ScreenOrientation,
            ev: ScreenOrientationEventMap[K],
        ) => any,
        options?: boolean | EventListenerOptions,
    ): void;
    removeEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | EventListenerOptions,
    ): void;
    unlock(): void;
}

Hierarchy

  • EventTarget
    • ScreenOrientation
Index
angle: number

The angle read-only property of the ScreenOrientation interface returns the document's current orientation angle.

MDN Reference

onchange: ((this: ScreenOrientation, ev: Event) => any) | null

The type read-only property of the ScreenOrientation interface returns the document's current orientation type, one of portrait-primary, portrait-secondary, landscape-primary, or landscape-secondary.

MDN Reference

  • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

    MDN Reference

    Type Parameters

    • K extends "change"

    Parameters

    Returns void

  • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

    MDN Reference

    Parameters

    Returns void

  • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

    MDN Reference

    Parameters

    • event: Event

    Returns boolean

  • The lock() method of the ScreenOrientation interface locks the orientation of the containing document to the specified orientation.

    MDN Reference

    Parameters

    Returns Promise<void>

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

    MDN Reference

    Type Parameters

    • K extends "change"

    Parameters

    Returns void

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

    MDN Reference

    Parameters

    Returns void

  • The unlock() method of the ScreenOrientation interface unlocks the orientation of the containing document, effectively locking it to the default screen orientation.

    MDN Reference

    Returns void

Was this helpful?