@bnidev/js-utils
    Preparing search index...

    Function onOrientationChange

    • Registers a callback to be invoked when the device orientation changes. Uses the Screen Orientation API. Returns an object with a stop method to remove the listener.

      Parameters

      • callback: (type: string, angle: number) => void

        Function to call with the orientation type and angle.

      Returns undefined | { stop: () => void }

      An object with a stop method to remove the event listener, or undefined if not supported.

      // ES Module
      import { onOrientationChange } from '@bnidev/js-utils'

      // CommonJS
      const { onOrientationChange } = require('@bnidev/js-utils')
      // Register a callback to log orientation changes
      const orientationListener = onOrientationChange((type, angle) => {
      console.log(`Orientation changed: ${type}, angle: ${angle}`)
      })