Content-Length: 571563 | pFad | http://github.com/NativeScript/plugins/commit/b924735de4a8d8c378c70513416a1401e81c91d7

1A chore(haptics): README improvements (#412) · NativeScript/plugins@b924735 · GitHub
Skip to content

Commit b924735

Browse files
authored
chore(haptics): README improvements (#412)
1 parent 344aef9 commit b924735

File tree

1 file changed

+64
-45
lines changed

1 file changed

+64
-45
lines changed

packages/haptics/README.md

+64-45
Original file line numberDiff line numberDiff line change
@@ -3,103 +3,122 @@
33
> Playing haptics can engage people's sense of touch and bring their familiarity with the physical world into your app or game.
44
~ Developer docs
55

6-
For iOS and Android development.
76

8-
Thank you to [Eddy Verbruggen](EddyVerbruggen) for providing [nativescript-taptic-engine](https://github.com/EddyVerbruggen/nativescript-taptic-engine) as this continues it's evolution by streamlining the API and adding Android support, inspired by [react-native-haptic-feedback](https://github.com/junina-de/react-native-haptic-feedback).
7+
Thanks to [Eddy Verbruggen](EddyVerbruggen) for providing [nativescript-taptic-engine](https://github.com/EddyVerbruggen/nativescript-taptic-engine) as this continues its evolution by streamlining the API and adding Android support, inspired by [react-native-haptic-feedback](https://github.com/junina-de/react-native-haptic-feedback).
98

10-
## Usage
9+
## Table of Contents
10+
* [Installation](#installation)
11+
* [API](#api)
12+
* [isSupported()](#issupported)
13+
* [is6SAnd6SPlusSupported()](#is6sand6splussupported)
14+
* [selection()](#selection)
15+
* [notifcation()](#notification)
16+
* [impact()](#impact)
17+
* [HapticsFallback](#hapticsfallback)
18+
* [weakBoom()](#weakboom)
19+
* [strongBoom()](#strongboom)
20+
* [burst()](#burst)
1121

12-
```javascript
22+
23+
## Installation
24+
25+
```cli
1326
npm install @nativescript/haptics
1427
```
1528

1629
## API
1730

18-
### `selection`
19-
Use selection feedback generators to indicate a change in selection.
31+
### isSupported()
32+
```ts
33+
isHapticsSupported: boolean = Haptics.isSupported()
34+
```
35+
Checks if Haptics is supported.
2036

21-
##### TypeScript
37+
---
38+
### is6SAnd6SPlusSupported()
39+
```ts
40+
isHapticsSupported: boolean = Haptics.is6SAnd6SPlusSupported()
41+
```
2242

23-
```js
24-
import { Haptics } from "@nativescript/haptics";
43+
Checks if Haptics is supported on iOS.
2544

26-
Haptics.selection();
27-
```
45+
---
46+
### selection()
2847

29-
##### JavaScript
30-
```js
31-
const Haptics = require("@nativescript/haptics").Haptics;
48+
```ts
49+
import { Haptics } from "@nativescript/haptics";
3250

3351
Haptics.selection();
3452
```
3553

36-
### `notification`
37-
Use notification feedback generators to indicate successes, failures, and warnings.
54+
### notification()
3855

39-
There are 3 notification types: `HapticNotificationType.SUCCESS` (default), `.WARNING`, and `.ERROR`.
40-
41-
##### TypeScript
42-
```js
56+
```ts
4357
import { Haptics, HapticNotificationType } from "@nativescript/haptics";
4458

4559
Haptics.notification(HapticNotificationType.ERROR);
4660
```
4761

48-
### `impact`
49-
Use impact feedback generators to indicate that an impact has occurred.
50-
For example, you might trigger impact feedback when a user interface object
51-
collides with something or snaps into place.
62+
Use notification feedback generators to indicate success, failure, and warning.
5263

53-
There are 3 impact styles: `HapticImpactType.LIGHT`, `.MEDIUM` (default), and `.HEAVY`.
64+
Other haptic notification types are:
65+
- `SUCCESS`(default)
66+
- `WARNING`
67+
68+
### impact()
5469

55-
##### TypeScript
5670
```js
5771
import { Haptics, HapticImpactType } from "@nativescript/haptics";
5872

5973
Haptics.impact(HapticImpactType.HEAVY);
6074
```
6175

76+
Use impact feedback generators to indicate that an impact has occurred.
77+
For example, you might trigger impact feedback when a user interface object
78+
collides with something or snaps into place.
79+
80+
There are 3 impact types:
81+
- `LIGHT`
82+
- `MEDIUM` (default)
83+
- `HEAVY`.
6284

63-
## HapticsFallback (requires at least iPhone 6s)
85+
### HapticsFallback
6486

65-
With older phones you can use the following conditional to use the fallbacks:
87+
To use the haptics fallbacks, first check if there is support:
6688

67-
```
89+
```ts
6890
if (!Haptics.isSupported() && Haptics.is6SAnd6SPlusSupported()) {
6991
// use HapticsFallback
7092
}
7193
```
7294

73-
__BEWARE__ This uses an undocumented feature which may get your app rejected when reviewed by Apple.
95+
__BEWARE__ This uses an undocumented feature that may get your app rejected when reviewed by Apple.
7496
[People have used this approach __without problems__ though.](http://stackoverflow.com/questions/32526868/taptic-in-ios-9)
7597

76-
### `weakBoom`
98+
### weakBoom()
7799
This triggers the same effect as the 'Peek' in 'Peek & Pop', a very brief vibration.
78100

79-
##### TypeScript
80-
```js
101+
```ts
81102
import { HapticsFallback } from "@nativescript/haptics";
82103

83104
HapticsFallback.weakBoom();
84105
```
85106

86-
##### JavaScript
87-
```js
88-
const HapticsFallback = require("@nativescript/haptics").HapticsFallback;
107+
### strongBoom()
108+
```ts
109+
import { HapticsFallback } from "@nativescript/haptics";
89110

90-
HapticsFallback.weakBoom();
111+
HapticsFallback.strongBoom();
91112
```
92-
93-
### `strongBoom`
94113
This triggers the 'Pop' effect of 'Peek & Pop', which is a bit more profound than the 'Peek' effect.
95114

96-
Codewise this is exactly the same as `weakBoom`, except for the function name of course.
97-
98-
99-
### `burst`
100-
This triggers the 'Nope' effect you get when fi. force touching a home icon which doesn't have any action. It's a short burst of 3-ish 'weak booms'.
115+
### burst()
116+
```ts
117+
import { HapticsFallback } from "@nativescript/haptics";
101118

102-
Codewise this is exactly the same as `weakBoom` and `strongBoom`, except for the function name of course.
119+
HapticsFallback.burst();
120+
```
121+
This triggers the 'Nope' effect you get when force-touching a home icon that doesn't have any action. It's a short burst of 3-ish 'weak booms'.
103122

104123
## Changelog
105124
* 3.0.0 Moved to @nativescript/haptics and added Android support. Adjusted naming conventions.

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/plugins/commit/b924735de4a8d8c378c70513416a1401e81c91d7

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy