Aller directement au contenu principal
Retour aux plugins
@capgo/capacitor-orientation de l'écran
Tutoriel
par github.com/Cap-go

Orientation de l'écran

Plugin d'orientation de l'écran avec prise en charge de la mise en cache de verrouillage d'orientation

Guide

Tutoriel sur l'Orientations de l'Ecran

Utilisation de @capgo/capacitor-screen-orientation

Capacitor Interface de l'Orientations de l'Ecran

Installer

bun add @capgo/capacitor-screen-orientation
bunx cap sync

Ce Plugin Expose

  • orientation - Récupérer l'orientation actuelle de l'écran.
  • lock - Bloquer l'orientation de l'écran à un type spécifique.
  • unlock - Débloquer l'orientation de l'écran.
  • startOrientationTracking - Suivez l'orientation du dispositif à l'aide de capteurs de mouvement.

Exemple d'utilisation

orientation

Obtenez l'orientation actuelle de l'écran.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

const result = await ScreenOrientation.orientation();
console.log('Current orientation:', result.type);

lock

Bloquez l'orientation de l'écran à un type spécifique.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

// Standard lock
await ScreenOrientation.lock({ orientation: 'landscape' });

// Lock with motion tracking on iOS
await ScreenOrientation.lock({
  orientation: 'portrait',
  bypassOrientationLock: true
});

unlock

Déverrouillez l'orientation de l'écran.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

await ScreenOrientation.unlock();

startOrientationTracking

Suivez l'orientation du dispositif à l'aide de capteurs de mouvement.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

await ScreenOrientation.startOrientationTracking({
  bypassOrientationLock: true
});

// Listen for changes
ScreenOrientation.addListener('screenOrientationChange', (result) => {
  console.log('Orientation changed:', result.type);
});

Référence complète