@capgo/capacitor-screen-orientationを使用します
Capacitor画面向きプラグインインターフェイス
インストール
bun add @capgo/capacitor-screen-orientation
bunx cap sync
このプラグインが公開するもの
orientation- 現在の画面向きを取得します。lock- 特定のタイプの画面向きにロックします。unlock- 画面向きをアンロックします。startOrientationTracking- モーションセンサを使用してデバイスの向きを追跡します。
例の使用
orientation
現在の画面向きを取得します。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
const result = await ScreenOrientation.orientation();
console.log('Current orientation:', result.type);
lock
特定のタイプに画面の向きを固定する
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
画面の向きを解除する
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.unlock();
startOrientationTracking
モーションセンサを使用してデバイスの向きを追跡する
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);
});
フルリファレンス
- GitHub: https://github.com/Cap-go/capacitor-screen-orientation/
- ドキュメント: /docs/plugins/screen-orientation/
capgoのcapacitor-screen-orientationから続ける
__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-screen-orientationを使用している場合 capgo/capacitor-screen-orientationを使用して ネイティブメディアとインターフェイスの動作を計画するには、@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-screen-orientationと接続する @capgo/capacitor-screen-orientationと接続する Capacitorの実装詳細については@capgo/capacitor-screen-orientationを参照してください。 Getting Started Capacitorの実装詳細についてはGetting Startedを参照してください。 Capacitorのライブアクティビティを使用するには@capgo/capacitor-live-activitiesを参照してください。 Capacitorのライブアクティビティを使用するには@capgo/capacitor-live-activitiesを参照してください。 Capacitorのライブアクティビティを使用するには@capgo/capacitor-live-activitiesを参照してください。 Capacitorのビデオプレーヤーを使用するにはUsing @capgo/capacitor-video-playerを参照してください。 Using @capgo/capacitor-video-player for the native capability in Using @capgo/capacitor-video-player.