ガイド
画面の向きに関するチュートリアル
@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から続けてください
Capacitorを使用している場合 Using @capgo/capacitor-screen-orientation Capacitorを使用してnativeメディアとインターフェイスの動作を計画している場合 @capgo/capacitor-screen-orientation for the implementation detail in @capgo/capacitor-screen-orientation, Capacitorを使用してnativeメディアとインターフェイスの動作を計画している場合 Capacitorを使用してnativeメディアとインターフェイスの動作を計画している場合 Using @capgo/capacitor-live-activities for the native capability in Using @capgo/capacitor-live-activities, @capgo/capacitor-live-activities capgo/capacitor-live-activitiesの実装詳細について Using @capgo/capacitor-video-player Using @capgo/capacitor-video-playerのネイティブ機能