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
- GitHub https://github.com/Cap-go/capacitor-orientation-de-l'écran/
- Documentation : /docs/plugins/orientation-de-l'écran/