@msobiecki/react-marauders-path 1.21.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@ A lightweight, type-safe React library for handling keyboard, wheel, swipe, and
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- 🎮 **Keyboard Event Handling** -
|
|
12
|
-
- 🎡 **Wheel Event Handling** -
|
|
13
|
-
- 🖐️ **Swipe Gesture Handling** -
|
|
14
|
-
- 🖱️ **Drag Event Handling** -
|
|
11
|
+
- 🎮 **Keyboard Event Handling** - Detect single keys, key combinations and sequences with configurable timing thresholds
|
|
12
|
+
- 🎡 **Wheel Event Handling** - Track wheel, delta values with optional `requestAnimationFrame` batching for smoother updates
|
|
13
|
+
- 🖐️ **Swipe Gesture Handling** - Detect directional swipes with configurable distance and velocity with pointer type filtering
|
|
14
|
+
- 🖱️ **Drag Event Handling** - Track movement, delta values, duration, start/end positions with pointer type filtering and optional `requestAnimationFrame` batching for smoother updates
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
@@ -23,7 +23,7 @@ npm install @msobiecki/react-marauders-path
|
|
|
23
23
|
|
|
24
24
|
### Key Event Hook
|
|
25
25
|
|
|
26
|
-
#### Single Key
|
|
26
|
+
#### Single Key Pattern
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
29
|
import { useKey } from '@msobiecki/react-marauders-path';
|
|
@@ -37,7 +37,7 @@ function MyComponent() {
|
|
|
37
37
|
}
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
#### Multiple
|
|
40
|
+
#### Multiple Single Key Patterns
|
|
41
41
|
|
|
42
42
|
```typescript
|
|
43
43
|
useKey(["a", "b", "c"], (event, key) => {
|
|
@@ -45,7 +45,7 @@ useKey(["a", "b", "c"], (event, key) => {
|
|
|
45
45
|
});
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
#### Combination
|
|
48
|
+
#### Key Combination Pattern
|
|
49
49
|
|
|
50
50
|
```typescript
|
|
51
51
|
useKey("a+b", (event, key) => {
|
|
@@ -53,7 +53,7 @@ useKey("a+b", (event, key) => {
|
|
|
53
53
|
});
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
#### Multiple
|
|
56
|
+
#### Multiple Key Combination Patterns
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
59
|
useKey(["a+b", "c+d"], (event, key) => {
|
|
@@ -61,7 +61,7 @@ useKey(["a+b", "c+d"], (event, key) => {
|
|
|
61
61
|
});
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
####
|
|
64
|
+
#### Key Sequence Pattern
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
67
|
useKey("ArrowUp ArrowUp ArrowDown ArrowDown", (event, key) => {
|
|
@@ -69,7 +69,7 @@ useKey("ArrowUp ArrowUp ArrowDown ArrowDown", (event, key) => {
|
|
|
69
69
|
});
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
#### Multiple
|
|
72
|
+
#### Multiple Key Sequence Patterns
|
|
73
73
|
|
|
74
74
|
```typescript
|
|
75
75
|
useKey(
|
|
@@ -100,7 +100,7 @@ function MyComponent() {
|
|
|
100
100
|
import { useSwipe } from '@msobiecki/react-marauders-path';
|
|
101
101
|
|
|
102
102
|
function MyComponent() {
|
|
103
|
-
useSwipe('left' (event, direction, data) => {
|
|
103
|
+
useSwipe('left', (event, direction, data) => {
|
|
104
104
|
console.log(`Swiped ${direction} with velocity ${data.velocity}`);
|
|
105
105
|
});
|
|
106
106
|
|
|
@@ -349,7 +349,7 @@ npm run dev
|
|
|
349
349
|
### Lint
|
|
350
350
|
|
|
351
351
|
```bash
|
|
352
|
-
npm lint
|
|
352
|
+
npm run lint
|
|
353
353
|
```
|
|
354
354
|
|
|
355
355
|
## Project Status
|