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.
インストール
「インストール」のセクション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.Manual Setupを使用する場合は、以下のコマンドを実行してプラットフォーム固有の指示を以下に従ってください。
bun add @capgo/capacitor-screen-orientationbunx cap syncImport
「Import」セクションimport { ScreenOrientation } from '@capgo/capacitor-screen-orientation';APIの概要
「APIの概要」セクションorientation
「orientation」セクション__CAPGO_KEEP_0__
__CAPGO_KEEP_1__
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
const result = await ScreenOrientation.orientation();console.log('Current orientation:', result.type);lock
__CAPGO_KEEP_3____CAPGO_KEEP_4__
__CAPGO_KEEP_5__
__CAPGO_KEEP_6__
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_8____CAPGO_KEEP_9__
__CAPGO_KEEP_10__
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.unlock();startOrientationTracking
startOrientationTrackingのセクションモーションセンサを使用してデバイスの向きを追跡します。
このメソッドは、画面の向きロックとは独立してデバイスの物理的な向きを追跡したい場合に便利です。 Core Motionを使用してiOSで向きの変更を検出します。
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のセクションモーションセンサを使用してデバイスの向きを追跡する機能を停止します。
motion-basedの向き追跡が開始されていた場合にのみ、モーションベースの向き追跡を停止します。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.stopOrientationTracking();isOrientationLocked
デバイスの向きロックが現在有効かどうかを確認します。このメソッドは、物理的なデバイスの向き(モーションセンサ)とUIの向きを比較します。 UIの向きと物理的なデバイスの向きが異なる場合、向きロックは有効です。 Note: このメソッドは、startOrientationTracking()またはlock()でbypassOrientationLock: trueを指定した場合にのみ動作します。 iOS (Core Motion)とAndroid (Accelerometer)両方で動作します。
クリップボードにコピー
__CAPGO_KEEP_0__
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);}__CAPGO_KEEP_1__
__CAPGO_KEEP_2__ScreenOrientationResult
__CAPGO_KEEP_3____CAPGO_KEEP_4__
export interface ScreenOrientationResult { /** * The current orientation type. * * @since 1.0.0 */ type: OrientationType;}OrientationLockOptions
__CAPGO_KEEP_5____CAPGO_KEEP_6__
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
__CAPGO_KEEP_8____CAPGO_KEEP_0__
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
Section titled “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
Section titled “OrientationType”デバイスの向きの状態を表す向きの種類。
export type OrientationType = 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';OrientationLockType
Section titled “OrientationLockType”デバイスの向きをロックするために使用できる向きのロックの種類。
export type OrientationLockType = | 'any' | 'natural' | 'landscape' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';このページはプラグインのソースから生成されています。 src/definitions.ts. upstream の API が変更されたときに、再度 sync を実行してください。
Getting Started から続けてください。
Getting Started から続けてください。あなたが「Getting Started」を使用している場合 Getting Started native メディアとインターフェイスの動作を計画するには、 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/capacitor-live-activities @capgo/capacitor-ビデオプレーヤー @capgo/capacitor-ビデオプレーヤーを使用して、ネイティブ機能を使用します。 @capgo/capacitor-ビデオプレーヤー @capgo/capacitor-ビデオプレーヤーの実装詳細を使用します。