|
@@ -27,6 +27,7 @@ import Trans from "./view/Trans";
|
|
|
import Closing from "./view/Closing";
|
|
|
|
|
|
import { useControls } from "leva";
|
|
|
+import Stats from "stats.js";
|
|
|
|
|
|
gsap.registerPlugin(ScrollTrigger);
|
|
|
|
|
@@ -40,8 +41,9 @@ let resizeTimer = null;
|
|
|
const defaultDebug = localStorage.getItem("debug") === "true" ? true : false;
|
|
|
function App() {
|
|
|
const container = useRef();
|
|
|
- const { debug } = useControls({
|
|
|
+ const { debug, stats } = useControls({
|
|
|
debug: defaultDebug,
|
|
|
+ stats: false,
|
|
|
});
|
|
|
const handlerResize = () => {
|
|
|
clearTimeout(resizeTimer);
|
|
@@ -71,12 +73,37 @@ function App() {
|
|
|
ScrollTrigger.getAll().forEach((ST) => ST.refresh(true));
|
|
|
}, 100);
|
|
|
};
|
|
|
+ if (document.querySelector("#page-process")) {
|
|
|
+ document.querySelector("#page-process").innerHTML = "100%";
|
|
|
+ }
|
|
|
+ document.body.style.overflow = "auto";
|
|
|
+ let timer = null;
|
|
|
+ function showStats() {
|
|
|
+ const statsInstance = new Stats();
|
|
|
+ statsInstance.dom.className = "stats";
|
|
|
+
|
|
|
+ function animate() {
|
|
|
+ statsInstance.begin();
|
|
|
+ // monitored code goes here
|
|
|
+ statsInstance.end();
|
|
|
+ requestAnimationFrame(animate);
|
|
|
+ }
|
|
|
+ statsInstance.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
|
|
|
+ document.body.appendChild(statsInstance.dom);
|
|
|
+ animate();
|
|
|
+ }
|
|
|
+
|
|
|
+ function hideStats() {
|
|
|
+ const eles = document.querySelector(".stats");
|
|
|
+ eles && document.body.removeChild(eles);
|
|
|
+ }
|
|
|
useEffect(() => {
|
|
|
window.addEventListener("resize", handlerResize, false);
|
|
|
handlerResize();
|
|
|
document.documentElement.style.overflow = "auto";
|
|
|
var vConsole = new window.VConsole();
|
|
|
localStorage.setItem("debug", debug);
|
|
|
+ localStorage.setItem("stats", stats);
|
|
|
if (debug) {
|
|
|
vConsole.showSwitch();
|
|
|
if (!defaultDebug) {
|
|
@@ -88,16 +115,19 @@ function App() {
|
|
|
}
|
|
|
vConsole.hideSwitch();
|
|
|
}
|
|
|
+ if (stats) {
|
|
|
+ showStats();
|
|
|
+ } else {
|
|
|
+ hideStats();
|
|
|
+ }
|
|
|
});
|
|
|
const props = {
|
|
|
- // scrollSpeed: scrollSpeed,
|
|
|
debug: debug,
|
|
|
};
|
|
|
|
|
|
return (
|
|
|
<div ref={container}>
|
|
|
<Opening></Opening>
|
|
|
-
|
|
|
<Section1 {...props} />
|
|
|
<Section2 {...props} />
|
|
|
<Section3 {...props} />
|