You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+3-6Lines changed: 3 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,9 +40,9 @@ The [example app](/example/) demonstrates usage of the library. You need to run
40
40
41
41
It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
42
42
43
-
If you want to use Android Studio or Xcode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/AhapExample.xcworkspace` in Xcode and find the source files at `Pods > Development Pods > react-native-ahap`.
43
+
If you want to use Android Studio or Xcode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/HaptixStudio.xcworkspace` in Xcode and find the source files at `Pods > Development Pods > react-native-ahaps`.
44
44
45
-
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-ahap` under `Android`.
45
+
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-ahaps` under `Android`.
46
46
47
47
You can use various commands from the root directory to work with the project.
48
48
@@ -67,7 +67,7 @@ yarn example ios
67
67
To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:
68
68
69
69
```sh
70
-
Running "AhapExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
70
+
Running "Haptix Studio" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
71
71
```
72
72
73
73
Note the `"fabric":true` and `"concurrentRoot":true` properties.
@@ -96,7 +96,6 @@ Remember to add tests for your change if possible. Run the unit tests by:
96
96
yarn test
97
97
```
98
98
99
-
100
99
### Commit message convention
101
100
102
101
We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
@@ -110,7 +109,6 @@ We follow the [conventional commits specification](https://www.conventionalcommi
110
109
111
110
Our pre-commit hooks verify that your commit message matches this format when committing.
112
111
113
-
114
112
### Publishing to npm
115
113
116
114
We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
@@ -121,7 +119,6 @@ To publish new versions, run the following:
121
119
yarn release
122
120
```
123
121
124
-
125
122
### Scripts
126
123
127
124
The `package.json` file contains various scripts for common tasks:
AHAP-style haptics (transient + continuous) on top of [Nitro Modules](https://nitro.margelo.com/) — the core functions are **UI-thread friendly** (`'worklet'`).
4
4
5
-
## Installation
5
+
> iOS only (Core Haptics). Android support could be added in the future, but it’s currently unplanned.
>`react-native-nitro-modules` is required as this library relies on [Nitro Modules](https://nitro.margelo.com/).
10
+
npm i react-native-ahaps react-native-nitro-modules
12
11
```
13
12
13
+
## Concepts (what to use when)
14
+
15
+
-**Transient**: Instant “click/tap” events. No duration — you trigger them at a point in time.
16
+
-**Continuous (pattern)**: Time-based patterns you _can_ define ahead of time. You provide **events** (with `duration`) and optionally **curves** (automation over time).
17
+
-**Continuous player (real-time)**: For _unpredictable_ input (gesture position, scroll velocity, real-time data). You create a player once, then **start → update (many times) → stop**.
18
+
19
+
### Why `events[]` and `curves[]` are separate
20
+
21
+
On iOS Core Haptics, a pattern is made of two different building blocks:
22
+
23
+
-**Events**: things that happen (transient “ticks” or continuous segments) at a `relativeTime`, with base `intensity`/`sharpness`.
24
+
-**Curves**: how parameters (intensity/sharpness) evolve over time via control points, independent of “what event” is currently playing.
25
+
26
+
They’re separate because they’re different object types in Core Haptics (events vs parameter curves) and they serve different jobs: **events define the structure**, **curves define the modulation**. You often combine both in one pattern.
14
27
15
28
## Usage
16
29
30
+
### Haptic “provider” (recommended)
31
+
32
+
Wrap your app inside `HapticsProvider`. This initializes the engine, creates the continuous player, and automatically destroys the engine when the app goes to background.
### Stop everything (recommended in screen cleanups)
155
+
156
+
Call `stopAllHaptics()` in your cleanup functions to terminate any ongoing continuous haptics. This prevents haptics from bleeding through to the next screen when navigating.
0 commit comments