@danchitnis/react-fps-stats
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -28,17 +28,2 @@ import React, { useState, useRef, useEffect } from 'react'; | ||
prevTime = currentTime; | ||
const maxFps = Math.max.apply(Math.max, fpsList); | ||
if (canvasMain.current) { | ||
const ctx = canvasMain.current.getContext("2d"); | ||
const w = canvasMain.current.width; | ||
const h = canvasMain.current.height; | ||
if (ctx) { | ||
ctx.clearRect(0, 0, w, h); | ||
ctx.fillStyle = barColor ? barColor : baseBarColor; | ||
fpsList.forEach((e, i) => { | ||
const rh = e / maxFps; | ||
const ri = capacity - i - 1; | ||
ctx.fillRect((ri * w) / capacity, h * (1 - rh), w / capacity, rh * h); | ||
}); | ||
} | ||
} | ||
} | ||
@@ -52,2 +37,19 @@ afRequest = requestAnimationFrame(calcFPS); | ||
}, []); | ||
useEffect(() => { | ||
const maxFps = Math.max.apply(Math.max, fps); | ||
if (canvasMain.current) { | ||
const ctx = canvasMain.current.getContext("2d"); | ||
const w = canvasMain.current.width; | ||
const h = canvasMain.current.height; | ||
if (ctx) { | ||
ctx.clearRect(0, 0, w, h); | ||
ctx.fillStyle = barColor ? barColor : baseBarColor; | ||
fps.forEach((e, i) => { | ||
const rh = e / maxFps; | ||
const ri = capacity - i - 1; | ||
ctx.fillRect((ri * w) / capacity, h * (1 - rh), w / capacity, rh * h); | ||
}); | ||
} | ||
} | ||
}, [fps]); | ||
const wrapperStyle = { | ||
@@ -54,0 +56,0 @@ zIndex: 100, |
@@ -33,17 +33,2 @@ 'use strict'; | ||
prevTime = currentTime; | ||
const maxFps = Math.max.apply(Math.max, fpsList); | ||
if (canvasMain.current) { | ||
const ctx = canvasMain.current.getContext("2d"); | ||
const w = canvasMain.current.width; | ||
const h = canvasMain.current.height; | ||
if (ctx) { | ||
ctx.clearRect(0, 0, w, h); | ||
ctx.fillStyle = barColor ? barColor : baseBarColor; | ||
fpsList.forEach((e, i) => { | ||
const rh = e / maxFps; | ||
const ri = capacity - i - 1; | ||
ctx.fillRect((ri * w) / capacity, h * (1 - rh), w / capacity, rh * h); | ||
}); | ||
} | ||
} | ||
} | ||
@@ -57,2 +42,19 @@ afRequest = requestAnimationFrame(calcFPS); | ||
}, []); | ||
React.useEffect(() => { | ||
const maxFps = Math.max.apply(Math.max, fps); | ||
if (canvasMain.current) { | ||
const ctx = canvasMain.current.getContext("2d"); | ||
const w = canvasMain.current.width; | ||
const h = canvasMain.current.height; | ||
if (ctx) { | ||
ctx.clearRect(0, 0, w, h); | ||
ctx.fillStyle = barColor ? barColor : baseBarColor; | ||
fps.forEach((e, i) => { | ||
const rh = e / maxFps; | ||
const ri = capacity - i - 1; | ||
ctx.fillRect((ri * w) / capacity, h * (1 - rh), w / capacity, rh * h); | ||
}); | ||
} | ||
} | ||
}, [fps]); | ||
const wrapperStyle = { | ||
@@ -59,0 +61,0 @@ zIndex: 100, |
{ | ||
"name": "@danchitnis/react-fps-stats", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "FPS Stats in React", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/danchitnis/react-fps-stats", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
341
215082