---
name: "offDeviceMotionChange"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.3.2" }
  - { name: "@ray-js/ray", version: "0.3.23" }
platform:
  - "iOS"
  - "Android"
async: true
title: "offDeviceMotionChange - 取消监听设备方向变化事件，参数为空，则取消所有的事件监听。"
---

## offDeviceMotionChange

> [VERSION] BaseKit >= 2.3.2 | @ray-js/ray >= 0.3.23

> [PLATFORM] iOS, Android

> ⚡ **支持 Promise 调用** — 不传 success / fail / complete 回调时，该方法返回 Promise。

### 描述

取消监听设备方向变化事件，参数为空，则取消所有的事件监听。

### 参数

`(listener: Function)`

| 参数 | 类型 | 必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| `listener` | `(params: Object) => void` | 是 | - |  |

##### offDeviceMotionChange.listener(params) 的属性

| 属性 | 类型 | 必填 | 默认值 | 最低版本 | 描述 |
| --- | --- | --- | --- | --- | --- |
| `alpha` | `number` | 是 | - | `2.3.2` | 当 手机坐标 X/Y 和 地球 X/Y 重合时，绕着 Z 轴转动的夹角为 alpha，范围值为 [0, 2*PI)。逆时针转动为正。 |
| `beta` | `number` | 是 | - | `2.3.2` | 当手机坐标 Y/Z 和地球 Y/Z 重合时，绕着 X 轴转动的夹角为 beta。范围值为 [-1*PI, PI) 。顶部朝着地球表面转动为正。也有可能朝着用户为正。 |
| `gamma` | `number` | 是 | - | `2.3.2` | 当手机 X/Z 和地球 X/Z 重合时，绕着 Y 轴转动的夹角为 gamma。范围值为 [-1*PI/2, PI/2)。右边朝着地球表面转动为正。 |
| `isParamCorrection` | `boolean` | 是 | - | `3.36.0` | 仅iOS有效，是否修正alpha值 |


### 示例代码

#### Demo

```tsx
import { onDeviceMotionChange, offDeviceMotionChange, stopDeviceMotionListening } from '@ray-js/ray'

// 取消方向监听：先注册一个监听，再 offDeviceMotionChange 取消（不传参 = 取消全部）。
// 末尾 stopDeviceMotionListening 的 success 回调作为用例完成信号
//（off 会移除监听组，TTT 需要一个明确的回调来判定用例结束）。
onDeviceMotionChange(e => console.log(e));

offDeviceMotionChange();

stopDeviceMotionListening({
  success: () => console.log("offDeviceMotionChange done"),
  fail: error => console.error(error),
});
```
