가이드
스크린 방향 설정 튜토리얼
@capgo/capacitor-스크린-방향-설정 사용
Capacitor 스크린 방향 설정 플러그인 인터페이스.
설치
bun add @capgo/capacitor-screen-orientation
bunx cap sync
이 플러그인은 다음을 제공합니다.
orientation- 현재 화면 방향을 가져옵니다.lock- 특정 유형의 화면 방향을 잠급니다.unlock- 화면 방향을 해제합니다.startOrientationTracking- 모션 센서를 사용하여 장치 방향을 추적합니다.
예제 사용
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);
});
전체 참조
- GitHub: https://github.com/Cap-go/capacitor-screen-orientation/
- 문서: /docs/plugins/screen-orientation/
capgo에서 capacitor-screen-orientation을 계속 사용하세요.
__CAPGO_KEEP_0__을 사용 중이라면 capgo/capacitor-screen-orientation을 사용하세요. 자연스러운 네이티브 미디어 및 인터페이스 동작을 계획하려면 __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-screen-orientation을 연결하세요. capgo/capacitor-screen-orientation을 사용하여 capgo/capacitor-screen-orientation의 구현 세부 정보를 연결하세요. for the implementation detail in @capgo/capacitor-screen-orientation, Getting Started의 구현 세부 정보를 연결하세요. __CAPGO_KEEP_0__에서 __CAPGO_KEEP_1__-live-activities를 사용하세요. capgo/capacitor-live-activities에서 사용하는 네이티브 기능을 위해 capgo/capacitor-live-activities를 사용하세요. for the native capability in Using @capgo/capacitor-live-activities, @capgo/capacitor-live-activities for the implementation detail in @capgo/capacitor-live-activities, and Using @capgo/capacitor-video-player for the native capability in Using @capgo/capacitor-video-player.