Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MotionMonitor

Hierarchy

  • MotionMonitor

Implements

Index

Constructors

constructor

Properties

Private isPermissionGranted

isPermissionGranted: boolean

Private Readonly isSupported

isSupported: boolean

Private listeners

listeners: MotionHandlersList = []

Methods

confirmPermissionGranted

  • confirmPermissionGranted(): this
  • Sets the flag that permission to listen to the motion events have already been granted to true

    Returns this

Private onMotion

  • onMotion(e: DeviceMotionEvent): void
  • Notifies all the motion event listeners that the motion event happened

    Parameters

    • e: DeviceMotionEvent

    Returns void

requestPermission

  • requestPermission(triggerElement?: HTMLElement): Promise<boolean>
  • IOS (since 12.2) requires a user's permission to listen to the motion events. Such permission could be obtained only in response to user interaction.

    This method sets a click listener on the provided element (on html if not provided) and returns a promise. Once the element clicked, it asks for permission. The promise will be resolved with a boolean reflecting the user's decision.

    If no such permission needed, the method returns resolved promise.

    Parameters

    • Default value triggerElement: HTMLElement = document.documentElement

    Returns Promise<boolean>

start

  • start(): this

stop

  • stop(): this

subscribe

unsubscribe

Generated using TypeDoc