メインコンテンツにジャンプ
@capgo/capacitor-画面の向き デバイスAPI オープンソース

画面向き Capacitor プラグイン

画面向きプラグインでロックを回避する機能をサポート

インストール

bun add @capgo/capacitor-screen-orientation bunx cap sync
npm、pnpmまたはyarn
  • npm install @capgo/capacitor-screen-orientation
  • pnpm add @capgo/capacitor-screen-orientation
  • yarn add @capgo/capacitor-screen-orientation

ガイド

How to use Screen Orientation in Capacitor

デバイスでテスト

Capgo アプリをダウンロードし、QR コード code をスキャンしてください。

スクリーン オリエンテーション プラグインのプレビュー QR code

@capgo/capacitor-screen-orientation を使用

Capacitor スクリーン オリエンテーション プラグイン インターフェイス

インストール

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

bunx cap sync プラグインのネイティブ code をあなたのネイティブ プロジェクトにコピーします。プラグインのアップグレード後は、もう一度実行してください。

インポート

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

API の概要

方法 説明
orientation 現在のスクリーン オリエンテーションを取得する
lock 特定のタイプのスクリーン オリエンテーションにロックする
unlock スクリーン オリエンテーションをアンロックする
startOrientationTracking モーション センサを使用してデバイス オリエンテーションを追跡する
stopOrientationTracking モーション センサを使用してデバイス オリエンテーションを停止する
isOrientationLocked デバイス オリエンテーション ロックが現在有効かどうかを確認する
isDeviceFoldable スクリーン オリエンテーション変更をリスンする
getFoldState 現在の折りたたみを読み取る
getHingeAngle 角度を読み取る
getReservedRegions スクリーンを覆うものも含めて折りたたみを読み取る
getBarPlacement iPhone Duoがネイティブのタブバーとツールバーを配置する場所を読み取る
setVerticalBarBehavior iPhone Duoがこのアプリのバーをサイドに移動できるかどうかを選択する
getSizeClass ウィンドウサイズのクラスを読み取る

例

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

stopOrientationTracking()

モーションセンサを使用してデバイスの向きを追跡を停止する

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

await ScreenOrientation.stopOrientationTracking();

isOrientationLocked()

デバイスの向きロックが現在有効になっているかどうかを確認します。

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

上の表には、13の基本メソッドがリストされています。リスナーとバージョンヘルパー、各メソッドの完全な契約書は、__CAPGO_KEEP_0__ リポジトリにドキュメントされています。 GitHub リポジトリ.

イベントをリスンする

addListener ハンドルを返します。画面がアンマウントされたとき、またはすべてのリスナーをクリアするときに呼び出してください。 handle.remove() 全体のリファレンス ScreenOrientation.removeAllListeners() ドキュメント

__CAPGO_KEEP_0__ リファレンス

@capgo/capacitor-screen-orientationを継続して使用してください。

Capacitor を使用している場合 Capacitor の @capgo/capacitor-screen-orientation native media とインターフェイスの動作を計画するには、を接続する Capacitor の @capgo/capacitor-screen-orientation @capgo/capacitor スクリーンオリエンテーション実装詳細 Capacitor の Getting Started Capacitor の Getting Started の実装詳細については、Getting Started を参照してください。 Capacitor の @capgo/capacitor-live-activities Capacitor の @capgo/capacitor-live-activities Capacitor の @capgo/capacitor-live-activities の実装詳細については、@capgo/capacitor-live-activities を参照してください。 Capacitor の @capgo/capacitor-live-activities Capacitor の @capgo/capacitor-video-player native capability in Using @capgo/capacitor-video-player.

FAQ

スクリーン オリエンテーション プラグイン FAQ

スクリーン オリエンテーション プラグインを Capacitor アプリにインストールするにはどうすればいいですか?

Run "bun add @capgo/capacitor-screen-orientation" (または "npm install @capgo/capacitor-screen-orientation"), すると iOS と Android のプロジェクトがネイティブ code を取得します。 それから、"bunx cap sync" を実行して iOS と Android のプロジェクトがネイティブ code を取得します。 そして、code で `@capgo/capacitor-screen-orientation` をインポートします。

React、Vue、Angular と @capgo/capacitor-screen-orientation はどのように関係していますか?

はい。 Screen Orientation は Capacitor パッケージなので、Ionic、React、Vue、Angular、Svelte、または単純な JavaScript など、Capacitor 内で実行される任意の Web フレームワークと互換性があります。

どの Capacitor バージョンが @capgo/capacitor-screen-orientation をサポートしていますか?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

@capgo/capacitor-screen-orientation は無料でオープンソースですか?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-screen-orientation/ and the package is free to install from npm. Bug reports and pull requests are welcome.

code を使用して Screen Orientation を更新することは App Store のレビューなしでできますか?

プラグインをインストールまたはアップグレードするとネイティブ code が変更されるため、ストアのビルドが必要になります。 その後、JavaScript、HTML、CSS の変更がプラグインを呼び出すと、Capgo のライブ更新で即時配信できます。

アプリレビューの待たずにスクリーン オリエンテーションを変更する

プラグインがストアビルドに追加されたら、Capgo ライブアップデートは、ユーザーにJavaScript、HTML、CSSの変更を数分でプッシュします。

Capgo で始めます