mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 07:13:44 +08:00
perf: Limit drawing frame rate
This commit is contained in:
parent
402f27b2a3
commit
6905b7a410
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user