본문으로 바로가기

__CAPGO_KEEP_0__ 가이드

화면 방향에 대한 __CAPGO_KEEP_0__ 튜토리얼

@capgo/capacitor-screen-orientation 사용

Capacitor 화면 방향 플러그인 인터페이스.

설치

bun add @capgo/capacitor-screen-orientation
bunx cap sync

이 플러그인이 제공하는 것

  • orientation - 현재 화면 방향을 가져옵니다.
  • lock - 화면 방향을 특정 유형으로 잠급니다.
  • unlock - 화면 방향을 해제합니다.
  • startOrientationTracking - __CAPGO_KEEP_0__ 기기를 이용한 방향을 추적하기 시작합니다.

예시 사용

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

전체 참조