__CAPGO_KEEP_1__

시작하기

GitHub

설치

설치

설치하기를 사용하여 플러그인을 설치할 수 있습니다. 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-orientation
bunx 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);

화면 방향을 특정 유형으로 고정합니다.

화면을 지정된 방향으로 고정합니다. iOS에서 bypassOrientationLock이 true일 경우, 물리적 장치 방향을 추적하기 시작합니다.

주의: 사용자의 방향 잠금 설정을 존중하는 UI가 여전히 있습니다. 물리적 장치 방향 추적을 허용하여 UI가 회전하지 않더라도 장치가 물리적으로 어떻게 들여 있는지 감지할 수 있습니다.

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
});

화면 방향을 해제합니다.

장치 위치에 따라 화면을 자유롭게 회전하도록 허용합니다. 또한 이전에 활성화된 물리적 장치 방향 추적도 중지합니다.

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);
});

기기 방향 추적 중지

운동 기반 방향 추적을 중지합니다.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.stopOrientationTracking();

기기 방향 잠금 확인

기기 방향 잠금이 현재 활성화되어 있는지 확인합니다.

Note: 이 기능은 motion tracking이 활성화되어야 하며 startOrientationTracking() 또는 lock() 함수를 사용하여 bypassOrientationLock: true로 설정해야 합니다. iOS (Core Motion)와 Android (Accelerometer) 모두 지원됩니다.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
// Start motion tracking first
await ScreenOrientation.startOrientationTracking({
bypassOrientationLock: true
});
// Check lock status
const status = await ScreenOrientation.isOrientationLocked();
if (status.locked) {
console.log('Orientation lock is ON');
console.log('Physical:', status.physicalOrientation);
console.log('UI:', status.uiOrientation);
}

타입 참조

타입 참조

스크린 오리엔테이션 결과

export interface ScreenOrientationResult {
/**
* The current orientation type.
*
* @since 1.0.0
*/
type: OrientationType;
}

스크린 오리엔테이션 잠금 옵션

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;
}

모션 센서를 사용한 오리엔테이션 트래킹 옵션

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. upstream에서 API가 변경되면 다시 싱크를 실행하세요.

Getting Started에서 계속

Getting Started에서 계속하기

Getting Started 시작하기 Getting Started Using @capgo/capacitor-screen-orientation native 기능을 사용하는 @capgo/capacitor-screen-orientation에 대한 원시 기능 @capgo/capacitor-live-activities native 기능을 사용하는 @capgo/capacitor-live-activities에 대한 원시 기능을위한 @capgo/capacitor-라이브-액티비티 @capgo/capacitor-live-활동 @capgo/capacitor-video-player native 기능을 사용하기 위해 @capgo/capacitor-video-player를 사용합니다. @capgo/capacitor-video-player @capgo/capacitor-video-player 구현 세부 사항을 위해.