mirror of
https://github.com/CrazyJasonwell/clash-verge-rev.git
synced 2026-10-21 07:18:43 +08:00
perf: Limit drawing frame rate
This commit is contained in:
1 parent
402f27b2a3
commit
6905b7a410
1 file changed
+4
@@ -147,6 +147,10 @@ export const TrafficGraph = forwardRef<TrafficRef>((props, ref) => {
|
|||||||
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const diff = now - lastTime;
|
const diff = now - lastTime;
|
||||||
|
if (diff < 33) {
|
||||||
|
raf = requestAnimationFrame(() => drawGraph(lastTime));
|
||||||
|
return;
|
||||||
|
}
|
||||||
const temp = Math.min((diff / 1000) * dx + countRef.current, dx);
|
const temp = Math.min((diff / 1000) * dx + countRef.current, dx);
|
||||||
const offset = countRef.current === 0 ? 0 : temp;
|
const offset = countRef.current === 0 ? 0 : temp;
|
||||||
countRef.current = temp;
|
countRef.current = temp;
|
||||||
|
|||||||
Reference in new issue
Block a user