Announcement: Tencent Cloud Mini Program Platform Renamed to Tencent Cloud Super App as a Service on January 2, 2025
Console Updates
Android SDK Updates
iOS SDK Updates
Flutter SDK Updates
IDE Updates
Base Library Updates
This API is called using wx.stopDeviceMotionListening(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
This API is called using wx.startDeviceMotionListening(Object object).
Property | Type | Default value | Required | Description |
interval | string | normal | False | The execution frequency of the callback function that listens for device orientation changes. Valid values: game: Callback frequency suitable for game updates, about 20 ms/time. ui: Callback frequency suitable for UI updates, about 60 ms/time. normal: Normal callback frequency, about 200 ms/time. |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
This API is called using wx.onDeviceMotionChange(function listener).
Property | Type | Description |
alpha | number | The angle around the Z-axis when the phone's X/Y coordinates align with the Earth's X/Y coordinates. The range is [0, 2*PI). Counterclockwise rotation is positive. |
beta | number | The angle around the X-axis when the phone's Y/Z coordinates align with the Earth's Y/Z coordinates. The range is [-1*PI, PI). Rotation towards the Earth's surface is positive. It may also be positive towards the user. |
gamma | number | The angle around the Y-axis when the phone's X/Z coordinates align with the Earth's X/Z coordinates. The range is [-1*PI/2, PI/2). Rotation towards the Earth's surface on the right side is positive. |
This API is called using wx.offDeviceMotionChange(function listener).
const listener = function (res) { console.log(res) }wx.onDeviceMotionChange(listener)wx.offDeviceMotionChange(listener) // Must pass the same function object used in onDeviceOrientationChange
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback