Zum Hauptinhalt springen
Zurück zu Plugins
@capgo/capacitor-Bildschirmorientierung
Tutorial
von github.com/Cap-go

Bildschirmorientierung

Bildschirmorientierungs-Plugin mit Unterstützung für die Umgehung der Orientierungs-Sperre

Richtlinie

Tutorial zur Bildschirmorientierung

Mit @capgo/capacitor-screen-orientation verwenden

Capacitor-Bildschirmorientierung-Plugin-Schnittstelle

Installieren

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

Was diese Erweiterung bereitstellt

  • orientation - Die aktuelle Bildschirmorientierung abrufen.
  • lock - Die Bildschirmorientierung auf eine bestimmte Art festlegen.
  • unlock - Die Bildschirmorientierung freigeben.
  • startOrientationTracking - Die Geräteorientierung mithilfe von Bewegungssensoren verfolgen.

Beispiel für die Verwendung

orientation

Die aktuelle Bildschirmorientierung abrufen.

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

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

lock

Die Bildschirmorientierung auf eine bestimmte Art festlegen.

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

Die Bildschirmorientierung freigeben.

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

await ScreenOrientation.unlock();

startOrientationTracking

Die Geräteorientierung mithilfe von Bewegungssensoren verfolgen.

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);
});

Vollständige Referenz

Weitermachen von Using @capgo/capacitor-Bildschirmorientierung

Wenn Sie Using @capgo/capacitor-Bildschirmorientierung zur Planung von nativen Medien und Schnittstellenverhalten verwenden, verbinden Sie es mit @capgo/capacitor-Bildschirmorientierung für die Implementierungsdetails in @capgo/capacitor-Bildschirmorientierung, Einstieg für die Implementierungsdetails in Einstieg, Using @capgo/capacitor-live-Aktivitäten für die native Fähigkeit in Using @capgo/capacitor-live-Aktivitäten, @capgo/capacitor-live-aktivitäten für die Implementierungsdetails in @capgo/capacitor-live-aktivitäten, und Mit @capgo/capacitor-video-player für die native Fähigkeit in Mit @capgo/capacitor-video-player.