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

画面向度

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

ガイド

画面向きのチュートリアル

デバイスでテスト

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

画面の向きを変更するプラグインのプレビューQRcode

@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を使用します。

If you are using native media and interface behaviorを計画するために@capgo/capacitor-screen-orientationを使用 @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-screen-orientationと接続 @capgo/capacitor-screen-orientationの実装詳細 for the implementation detail in @capgo/capacitor-screen-orientation, Getting Startedの実装詳細 native capabilityを使用する@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-live-activities Using @capgo/capacitor-live-activities @capgo/capacitor-live-activitiesの実装詳細 Using @capgo/capacitor-video-player native capabilityを使用する@capgo/capacitor-video-player native capabilityを使用する@capgo/capacitor-video-player ネイティブ機能の使用に@capgo/capacitor-video-playerを使用します。