https://github.com/candlefinance/haptics
Haptics for React Native with support for custom patterns and ahap files.
https://github.com/candlefinance/haptics
ahap corehaptics haptics ios react-native uifeedbackgenerator uikit
Last synced: about 1 year ago
JSON representation
Haptics for React Native with support for custom patterns and ahap files.
- Host: GitHub
- URL: https://github.com/candlefinance/haptics
- Owner: candlefinance
- License: mit
- Created: 2023-09-28T15:07:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-12T14:33:53.000Z (over 2 years ago)
- Last Synced: 2024-04-20T17:41:35.851Z (about 2 years ago)
- Topics: ahap, corehaptics, haptics, ios, react-native, uifeedbackgenerator, uikit
- Language: Swift
- Homepage: https://candle.fi
- Size: 1.71 MB
- Stars: 54
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Haptics for React Native
Supports playing haptics on iOS with default UIImpactFeedbackGenerator and CoreHaptics for patterns and ahap files. Vibrates on Android.
## Installation
```sh
yarn add @candlefinance/haptics
```
```sh
npm i @candlefinance/haptics
```
## Basic Usage
There are three functions:
```js
import { haptic, hapticWithPattern } from '@candlefinance/haptics';
// light, medium, heavy, soft, rigid, warning, error, success, selectionChanged
haptic('medium');
// pattern (iOS only)
hapticWithPattern(['.', '.', '.', 'o', 'O', '-', 'O', 'o', '.', '.', '.', '.']);
// play ahap file (iOS only)
play('fileName');
```
The pattern format:
```
- 'o' - medium impact
- 'O' - heavy impact
- '.' - light impact
- ':' - soft impact
- '-' - wait of 0.1 second
- '=' - wait of 1 second
```
For playing ahap files to the root of your project add a folder called `haptics` and add your ahap files there. Use (Haptrix)[https://www.haptrix.com/] or equivalent to generate ahap files.
## Contributing
Join our [Discord](https://discord.gg/qnAgjxhg6n) and ask questions in the **#oss** channel.
## License
MIT