メインコンテンツにジャンプ
プラグインに戻る
@capgo/capacitor-screen-orientation
チュートリアル
@capgo/capacitor-screen-orientation

画面向き

画面向きプラグインは、画面の向きロックを回避する機能をサポートしています。

Guide

Tutorial on Screen Orientation

Using @capgo/capacitor-screen-orientation

Capacitor Screen Orientation Plugin interface.

Install

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

What This Plugin Exposes

  • orientation - Get the current screen orientation.
  • lock - Lock the screen orientation to a specific type.
  • unlock - Unlock the screen orientation.
  • startOrientationTracking - Start tracking device orientation using motion sensors.

例外使用

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

フルリファレンス

「@capgo/capacitor-screen-orientation」を使用している場合

@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-screen-orientationを使用している場合 「@capgo/capacitor-screen-orientation」を使用している場合 nativeメディアとインターフェイスの動作を計画し、 @capgo/capacitor-screen-orientation @capgo/capacitor-screen-orientationの実装詳細について Getting Started Getting Startedの実装詳細について @capgo/capacitor-live-activities @capgo/capacitor-live-activitiesのnative機能について @capgo/capacitor-live-activities @capgo/capacitor-live-activitiesの実装詳細について @capgo/capacitor-video-player @capgo/capacitor-video-playerのnative機能について