提交 e30923f4 编写于 作者: M mehaotian

fix(App): accelerometer listener

上级 e79c02b0
......@@ -28,9 +28,8 @@ export const offAccelerometerChange = <API_TYPE_OFF_ACCELEROMETER_CHANGE>(
export const startAccelerometer = <API_TYPE_START_ACCELEROMETER>(
defineAsyncApi(API_START_ACCELEROMETER, (_, { resolve, reject }) => {
listener =
listener ||
plus.accelerometer.watchAcceleration(
if (!listener) {
listener = plus.accelerometer.watchAcceleration(
(res) => {
UniServiceJSBridge.invokeOnCallback(API_ON_ACCELEROMETER, {
x: (res && res.xAxis) || 0,
......@@ -46,6 +45,7 @@ export const startAccelerometer = <API_TYPE_START_ACCELEROMETER>(
frequency: DEVICE_FREQUENCY,
}
)
}
setTimeout(resolve, DEVICE_FREQUENCY)
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册