@stroke-stabilizer/vue 0.2.13 → 0.2.15
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 +24 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -32,12 +32,17 @@ const { process, reset, pointer } = useStabilizedPointer({
|
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
function handlePointerMove(e: PointerEvent) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
// IMPORTANT: Use getCoalescedEvents() for smoother input
|
|
36
|
+
const events = e.getCoalescedEvents?.() ?? [e]
|
|
37
|
+
|
|
38
|
+
for (const ce of events) {
|
|
39
|
+
process({
|
|
40
|
+
x: ce.offsetX,
|
|
41
|
+
y: ce.offsetY,
|
|
42
|
+
pressure: ce.pressure,
|
|
43
|
+
timestamp: ce.timeStamp,
|
|
44
|
+
})
|
|
45
|
+
}
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
function handlePointerUp() {
|
|
@@ -52,6 +57,8 @@ function handlePointerUp() {
|
|
|
52
57
|
</template>
|
|
53
58
|
```
|
|
54
59
|
|
|
60
|
+
> **Important:** Always use `getCoalescedEvents()` to capture all pointer events between frames. Without it, browsers throttle events and you'll get choppy strokes.
|
|
61
|
+
|
|
55
62
|
### With rAF Batch Processing
|
|
56
63
|
|
|
57
64
|
For high-frequency input devices, use the underlying `StabilizedPointer`'s batch processing:
|
|
@@ -74,12 +81,17 @@ onUnmounted(() => {
|
|
|
74
81
|
})
|
|
75
82
|
|
|
76
83
|
function handlePointerMove(e: PointerEvent) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
// IMPORTANT: Use getCoalescedEvents() for smoother input
|
|
85
|
+
const events = e.getCoalescedEvents?.() ?? [e]
|
|
86
|
+
|
|
87
|
+
for (const ce of events) {
|
|
88
|
+
pointer.value.queue({
|
|
89
|
+
x: ce.offsetX,
|
|
90
|
+
y: ce.offsetY,
|
|
91
|
+
pressure: ce.pressure,
|
|
92
|
+
timestamp: ce.timeStamp,
|
|
93
|
+
})
|
|
94
|
+
}
|
|
83
95
|
}
|
|
84
96
|
</script>
|
|
85
97
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stroke-stabilizer/vue",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"description": "Vue composables for stroke stabilization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"typecheck": "tsc --noEmit"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@stroke-stabilizer/core": "^0.2.
|
|
25
|
+
"@stroke-stabilizer/core": "^0.2.14"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"vue": ">=3.0.0"
|