使用する @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
Using @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-screen-orientation Capacitorを使用してnativeメディアとインターフェイスの動作を計画している場合、@capgo/capacitor-screen-orientationを接続する Capacitorを使用してnativeメディアとインターフェイスの動作を計画している場合、@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-screen-orientationを接続する Capacitorを使用してnativeメディアとインターフェイスの動作を計画している場合、@capgo/capacitor-screen-orientationを接続する 実装詳細については @capgo/capacitor-screen-orientation に Getting Started 実装詳細については Getting Started に Using @capgo/capacitor-live-activities Using @capgo/capacitor-live-activities のネイティブ機能については @capgo/capacitor-live-activities Using @capgo/capacitor-live-activities の実装詳細については Using @capgo/capacitor-video-player Using @capgo/capacitor-video-player のネイティブ機能については