tencent cloud

Tencent Cloud Super App as a Service

Screen Orientation

Download
Focus Mode
Font Size
Last updated: 2025-04-10 18:18:36

onDeviceOrientationChange

This API is called using wx.onDeviceOrientationChange(function listener).
Feature description:Listens for screen orientation change event.
Parameter and description: function listener.The function that handles screen orientation change event. Parameters are as follows:
Property
Type
Description
value
string
The new screen orientation.
landscape: Landscape mode with the HOME button on the right.
landscapeReverse: Landscape mode with the HOME button on the left.
Note:wx.onDeviceOrientationChange only listens for changes between left and right landscape orientations and is effective only when deviceOrientation is set to landscape in game.json.

offDeviceOrientationChange

This API is called using wx.offDeviceOrientationChange(function listener).
Feature description:Removes the listener for screen orientation change event.
Parameter and description: function listener.The function that was passed to onDeviceOrientationChange. If not provided, all listeners will be removed.
Example:
const listener = function (res) { console.log(res) }

wx.onDeviceOrientationChange(listener)
wx.offDeviceOrientationChange(listener) // Must pass the same function object used in onDeviceOrientationChange



Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback