Commit f33c613
authored
Fix: Skillcheck animation speed inconsistencies by switching to time-… (#66)
* Fix: Skillcheck animation speed inconsistencies by switching to time-based RAF loop
This PR fixes long-standing issues with the skillcheck mini-game animation speed being inconsistent across machines and after long play sessions. Some players reported extremely slow indicator movement, others extremely fast, and many noticed that the speed changed unpredictably the longer they stayed logged in.
The root cause was that the skillcheck relied on a useInterval tick (setInterval-like behavior) and assumed it fired every 1ms. In reality, browser timer clamping and throttling make interval timing highly unpredictable — especially in embedded CEF browsers like FiveM’s NUI.
This PR replaces tick-based animation with a time-based requestAnimationFrame loop using performance.now(), ensuring perfectly consistent animation timing across all hardware and browser states. I have used this method in other NUI based skillcheck scripts to address this same behavior.
Signed-off-by: Senlar <brandonrhue@gmail.com>
* Refactor keyHandler and clean up code
Signed-off-by: Senlar <brandonrhue@gmail.com>
* Refactor keyHandler and cleanup useEffect logic again
Signed-off-by: Senlar <brandonrhue@gmail.com>
---------
Signed-off-by: Senlar <brandonrhue@gmail.com>1 parent e66b680 commit f33c613
1 file changed
+74
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
15 | 23 | | |
16 | 24 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
23 | 65 | | |
24 | 66 | | |
25 | 67 | | |
| |||
42 | 84 | | |
43 | 85 | | |
44 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
45 | 90 | | |
46 | | - | |
47 | | - | |
| 91 | + | |
48 | 92 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
55 | 100 | | |
56 | 101 | | |
57 | | - | |
| 102 | + | |
58 | 103 | | |
59 | 104 | | |
60 | 105 | | |
61 | | - | |
62 | | - | |
| 106 | + | |
63 | 107 | | |
| 108 | + | |
64 | 109 | | |
65 | 110 | | |
66 | 111 | | |
67 | 112 | | |
68 | 113 | | |
69 | 114 | | |
70 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
71 | 124 | | |
72 | 125 | | |
73 | 126 | | |
| |||
0 commit comments