my.offDeviceMotionChange

Stop listening for device orientation change events.

Supported types of mini programs: DSL, H5+

Parameters

Type

Required

Description

Function listener

Yes

The listener function that is passed to my.onDeviceMotionChange. If this parameter is not specified, all my.onDeviceMotionChange listeners are removed.

Sample Code

DSL

Remove a specific listener

copy
//Define the listener function.
var listener = function (res) {
    console.log(res.alpha);
    console.log(res.beta);
    console.log(res.gamma);
}

//Listen for the device orientation change event.
my.onDeviceMotionChange(this.listener);

//Remove the listener.
my.offDeviceMotionChange(this.listener)

Remove all listeners

copy
my.offDeviceMotionChange()

H5+

copy
document.removeEventListener('deviceMotionChange', deviceMotionChangeHandler);