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

画面向き

画面向きをサポートするプラグインで、画面向きロックをバイパスすることができます。

ガイド

画面の向きを制御するチュートリアル

デバイスでテスト

Download the Capgo app, then scan the QR code.

画面向きプラグインプレビューQR code

@capgo/capacitor-screen-orientationを使用します

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

フルリファレンス

capgoのcapacitor-screen-orientationから続ける

__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-screen-orientationを使用している場合 capgo/capacitor-screen-orientationを使用して ネイティブメディアとインターフェイスの動作を計画するには、@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-screen-orientationと接続する @capgo/capacitor-screen-orientationと接続する Capacitorの実装詳細については@capgo/capacitor-screen-orientationを参照してください。 Getting Started Capacitorの実装詳細についてはGetting Startedを参照してください。 Capacitorのライブアクティビティを使用するには@capgo/capacitor-live-activitiesを参照してください。 Capacitorのライブアクティビティを使用するには@capgo/capacitor-live-activitiesを参照してください。 Capacitorのライブアクティビティを使用するには@capgo/capacitor-live-activitiesを参照してください。 Capacitorのビデオプレーヤーを使用するにはUsing @capgo/capacitor-video-playerを参照してください。 Using @capgo/capacitor-video-player for the native capability in Using @capgo/capacitor-video-player.