1.0.7 • Published 4 years ago

@uni/accelerometer v1.0.7

Weekly downloads
65
License
BSD-3-Clause
Repository
github
Last release
4 years ago

accelerometer

npm

Accelerometer monitor and cancel.

Support

Install

$ npm install @uni/accelerometer --save

Methods

onChange(callback): void

Monitoring acceleration data, the callback interval is 500ms, the interactive calls will automatically start listening, can use offChange() to stop listening.

Parameters

PropertyTypeDescriptionSupport
callbackFunctionThe callback function

offChange(): void

Stop listening for acceleration data.

是否需要传 callback 值

If the callback value is not passed, all event callbacks will be removed. The sample code is as follows:

accelerometer.offChange();

Pass the callback value and only remove the corresponding callback event. The sample code is as follows:

accelerometer.offChange(this.callback);

Example

import accelerometer from '@uni/accelerometer';

accelerometer.onChange(res => {
  console.log(res.x);
  console.log(res.y);
  console.log(res.z);
});

accelerometer.offChange();

You can also import from the big package:

import {accelerometer} from '@uni/apis';
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.4-beta

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-beta1

4 years ago

1.0.0-beta

4 years ago