14日間無制限の無料試用版。クレジットカードは必要ありません
このプラグインのインストール手順とマークダウンガイドの全体を含むセットアップコマンドをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-screen-orientation`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/screen-orientation/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Install
ペースト用に準備CapgoのAI-Assistedセットアップを使用してプラグインをインストールできます。次のコマンドを使用して、CapgoスキルをAIツールに追加してください。
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のコマンドを使用してください:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-screen-orientation` plugin in my project.手動設定を使用する場合は、以下のコマンドを実行してください。プラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-screen-orientationbunx cap syncインポート
__CAPGO_KEEP_0__の概要import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';APIの概要
APIorientation
「向き」セクション現在の画面向きを取得します。
画面の向きを取得します。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
const result = await ScreenOrientation.orientation();console.log('Current orientation:', result.type);lock
「ロック」セクション画面向きを特定のタイプに固定します。
指定された向きで画面を固定します。 iOSでは、bypassOrientationLockがtrueの場合、物理的なデバイス向きをモーションセンサで追跡します。
注意: UIはユーザーの向きロック設定を尊重します。 モーション追跡により、UIが回転しない場合でも、デバイスが物理的に保持されているかどうかを検出できます。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
// Standard lockawait ScreenOrientation.lock({ orientation: 'landscape' });
// Lock with motion tracking on iOSawait ScreenOrientation.lock({ orientation: 'portrait', bypassOrientationLock: true});unlock
「アンロック」セクション画面向きをアンロックします。
デバイスの位置に応じて画面を自由に回転させます。 また、モーションベースの向き追跡も停止します。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.unlock();startOrientationTracking
「startOrientationTracking」セクションモーションセンサを使用してデバイスの向きを追跡します。
このメソッドは、画面の向きロックとは独立してデバイスの物理的な向きを追跡したい場合に便利です。 iOSではCore Motionを使用して向きの変化を検出します。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.startOrientationTracking({ bypassOrientationLock: true});
// Listen for changesScreenOrientation.addListener('screenOrientationChange', (result) => { console.log('Orientation changed:', result.type);});stopOrientationTracking
「stopOrientationTracking」セクションモーションセンサを使用してデバイスの向きの追跡を停止します。
モーションセンサを使用しての向きの追跡を停止します。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.stopOrientationTracking();isOrientationLocked
「isOrientationLocked」セクションデバイスの向きロックが現在有効かどうかを確認します。
このメソッドは、物理的なデバイスの向き(モーションセンサ)とUIの向きを比較します。 向きが異なる場合、向きロックは有効です。
Note: この機能は、startOrientationTracking() または lock() を使用してバイパスオリエンテーションロックを有効にし、モーショントラッキングが有効になっている場合にのみ機能します。 iOS (Core Motion) と Android (Accelerometer) の両方で動作します。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
// Start motion tracking firstawait ScreenOrientation.startOrientationTracking({ bypassOrientationLock: true});
// Check lock statusconst status = await ScreenOrientation.isOrientationLocked();if (status.locked) { console.log('Orientation lock is ON'); console.log('Physical:', status.physicalOrientation); console.log('UI:', status.uiOrientation);}型の参照
型の参照ScreenOrientationResult
画面のオリエンテーション結果画面のオリエンテーションロックのオプション
export interface ScreenOrientationResult { /** * The current orientation type. * * @since 1.0.0 */ type: OrientationType;}OrientationLockOptions
モーショントラッキングの開始オプション型の参照
export interface OrientationLockOptions { /** * The orientation type to lock to. * * @since 1.0.0 */ orientation: OrientationLockType;
/** * Whether to track physical device orientation using motion sensors. * When true, uses device motion sensors to detect the true physical * orientation of the device, even when the device orientation lock is enabled. * * **Important:** This does NOT bypass the UI orientation lock. * The screen will still respect the user's orientation lock setting. * This option only affects orientation detection/tracking - you'll receive * orientation change events based on how the device is physically held, * but the UI will not rotate if orientation lock is enabled. * * Supported on iOS (Core Motion) and Android (Accelerometer). * * @default false * @since 1.0.0 */ bypassOrientationLock?: boolean;}StartOrientationTrackingOptions
画面のオリエンテーションロックのオプション画面のオリエンテーション結果
export interface StartOrientationTrackingOptions { /** * Whether to track physical device orientation using motion sensors. * When true, uses device motion sensors to detect the true physical * orientation of the device, even when the device orientation lock is enabled. * * **Important:** This does NOT bypass the UI orientation lock. * This only enables detection of the physical orientation. * * Supported on iOS (Core Motion) and Android (Accelerometer). * * @default false * @since 1.0.0 */ bypassOrientationLock?: boolean;}OrientationLockStatusResult
「OrientationLockStatusResult」セクションisOrientationLocked() メソッドが返す結果
export interface OrientationLockStatusResult { /** * Whether the device orientation lock is currently enabled. * * This is determined by comparing the physical device orientation * (from motion sensors) with the UI orientation. If they differ, * orientation lock is enabled. * * Available on iOS (Core Motion) and Android (Accelerometer) when motion tracking is active. * * @since 1.0.0 */ locked: boolean;
/** * The physical orientation of the device from motion sensors. * Available when motion tracking is active (iOS and Android). * * @since 1.0.0 */ physicalOrientation?: OrientationType;
/** * The current UI orientation reported by the system. * * @since 1.0.0 */ uiOrientation: OrientationType;}OrientationType
「OrientationType」セクションデバイスの向きを表すオリエンテーションタイプ
export type OrientationType = 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';OrientationLockType
「OrientationLockType」セクションデバイスの向きをロックするためのオリエンテーションロックタイプ
export type OrientationLockType = | 'any' | 'natural' | 'landscape' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';真実の源
「真実の源」セクションこのページはプラグインから生成されます。 src/definitions.ts. 再度、パブリック API がアップストリームで変更されたときは、再度同期を実行してください。
続けてGetting Started
セクションのタイトルは「続けてGetting Started」あなたが使用している場合 はじめに ネイティブメディアとインターフェイスの動作を計画する場合、接続してください ネイティブ機能の@capgo/capacitor-screen-orientation ネイティブ機能の@capgo/capacitor-screen-orientation ネイティブ機能の@capgo/capacitor-live-activities ネイティブ機能の@capgo/capacitor-live-activities @capgo/capacitor-ライブアクティビティ @capgo/capacitorライブアクティビティの実装詳細のために @capgo/capacitor-ビデオプレーヤー for the native capability in Using @capgo/capacitor-video-player, and @capgo/capacitor-ビデオプレーヤー @capgo/capacitor-ビデオ・プレーヤーの実装詳細について。