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

画面向き

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

ガイド

画面の向きに関するチュートリアル

デバイスでテスト

Capgoアプリをダウンロードし、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

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