my.offAccelerometerChange

Use this API to stop listening to acceleration data change event.

Supported types of mini programs: DSL, H5, H5+

Sample Code

DSL

copy
my.offAccelerometerChange();

H5, H5+

copy
AlipayJSBridge.call('watchShake', {
    monitorAccelerometer: true
}, function (res) {
});
function accelerometerChangehandler(res) {
  console.log(JSON.stringify(res))
}
document.addEventListener('accelerometerChange', accelerometerChangehandler);
document.removeEventListener('accelerometerChange', accelerometerChangehandler);

Whether to pass callback value or not

  • If the callback value is not passed, the callbacks of all events will be removed. The sample code is as follows:
copy
my.offAccelerometerChange();
  • If the callback value is passed, only the corresponding callback is removed. The sample code is as follows:
copy
my.offAccelerometerChange(this.callback);