Getting Started
このプラグインのセットアップコマンドとインストールステップ、そしてフルマークダウンガイドを含むコピー可能なものを取得します。
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.
インストール
「インストール」のセクションCapgoのAIアシストセットアップを使用してプラグインをインストールできます。次のコマンドを使用して、AIツールにCapgoスキルを追加します。
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.CapgoのAIアシストセットアップを使用せずにプラグインをインストールする場合は、以下のコマンドを実行し、下記のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-screen-orientationbunx cap syncインポート
「インポート」のセクションimport { ScreenOrientation } from '@capgo/capacitor-screen-orientation';APIの概要
APIの概要orientation
画面の向き現在の画面の向きを取得します。
デバイスの画面の現在の向きを返します。
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
画面の向きを解除します。__CAPGO_KEEP_0__の概要
デバイスの位置に応じて画面を自由に回転させることができます。 また、モーションに基づくオーリエンテーション追跡が有効になっていた場合に、その追跡を停止します。
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の向きを比較します。 向きが異なる場合、向きロックが有効になります。
注意: この機能は、startOrientationTracking()またはlock()でbypassOrientationLock: trueを指定することでモーション追跡を有効にする必要があります。 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
「オーリエンテーションロックステータス結果」のセクションロック状態を確認する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
「オーリエンテーションタイプ」のセクションデバイスのオーリエンテーション状態を表すオーリエンテーションタイプ。
export type OrientationType = 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';OrientationLockType
「オーリエンテーションロックタイプ」のセクションデバイスのオーリエンテーションをロックするために使用できるオーリエンテーションロックタイプ。
export type OrientationLockType = | 'any' | 'natural' | 'landscape' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';真実の源
「ソース オブ トゥルース」このページはプラグインの src/definitions.tsパブリック API がアップストリームで変更されたときは、再度同期を実行してください。
「Getting Started」から続けてください。
「Getting Started」から続けてください。「Getting Started」を使用している場合 Getting Started ネイティブメディアとインターフェイスの動作を計画するには、 Using @capgo/capacitor-screen-orientation Using @capgo/capacitor-screen-orientation Using @capgo/capacitor-live-activities Using @capgo/capacitor-live-activities @capgo/capacitor-live-activities Capgo @capgo/capacitor-live-activitiesの実装詳細について Capgo @capgo/capacitor-video-playerを使用 Capgo @capgo/capacitor-video-playerのネイティブ機能を使用 @capgo/capacitor-video-player Capgo @capgo/capacitor-video-playerの実装詳細について