Guida
Tutorial sull'orientamento della schermata
Utilizzo di @capgo/capacitor-orientamento-schermata
Capacitor Interfaccia plugin orientamento schermata
Installa
bun add @capgo/capacitor-screen-orientation
bunx cap sync
Cosa esporre questo plugin
orientation- Ottieni l'orientamento della schermata corrente.lock- Blocca l'orientamento della schermata a un tipo specifico.unlock- Sblocca l'orientamento della schermata.startOrientationTracking- Utilizza i sensori di movimento per tracciare l'orientamento del dispositivo.
Esempio di utilizzo
orientation
Ottieni l'orientamento attuale della schermata.
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
const result = await ScreenOrientation.orientation();
console.log('Current orientation:', result.type);
lock
Blocca l'orientamento della schermata a un tipo specifico.
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
Sblocca l'orientamento della schermata.
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.unlock();
startOrientationTracking
Utilizza i sensori di movimento per tracciare l'orientamento del dispositivo.
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);
});
Riferimento completo
- GitHub https://github.com/Cap-go/capacitor-orientamento-schermo/
- Documentazione: /docs/plugins/orientamento-schermo/