1
0
mirror of https://github.com/morris/vanilla-todo.git synced 2025-08-21 13:21:29 +02:00

remove fps, improve icon css

This commit is contained in:
Morris Brodersen
2024-02-02 17:47:36 +01:00
parent 8ef7022267
commit 881b44f156
5 changed files with 11 additions and 54 deletions

View File

@@ -1,36 +0,0 @@
/**
* @param {HTMLElement} el
*/
export function AppFps(el) {
const sampleSize = 20;
let times = [];
tick();
function tick() {
requestAnimationFrame(tick);
times.push(performance.now());
if (times.length <= sampleSize) return;
let min = Infinity;
let max = 0;
let sum = 0;
for (let i = 1; i < sampleSize + 1; ++i) {
const delta = times[i] - times[i - 1];
min = Math.min(min, delta);
max = Math.max(max, delta);
sum += delta;
}
const fps = (sampleSize / sum) * 1000;
el.innerText = `${fps.toFixed(0)} fps (${min.toFixed(0)} ms - ${max.toFixed(
0,
)} ms)`;
times = [];
}
}

View File

@@ -1,6 +1,5 @@
import { AppCollapsible } from './AppCollapsible.js';
import { AppFlip } from './AppFlip.js';
import { AppFps } from './AppFps.js';
import { AppIcon } from './AppIcon.js';
import { TodoController } from './TodoController.js';
import { TodoFrameCustom } from './TodoFrameCustom.js';
@@ -15,8 +14,9 @@ export function TodoApp(el) {
el.innerHTML = /* html */ `
<header class="app-header">
<h1 class="title">VANILLA TODO</h1>
<p class="app-fps fps"></p>
<h1 class="title">
VANILLA TODO
</h1>
</header>
<div class="todo-frame -days"></div>
<div class="app-collapsible">
@@ -31,7 +31,7 @@ export function TodoApp(el) {
</div>
<footer class="app-footer">
<p>
VANILLA TODO &copy; 2020&ndash;2023 <a href="https://morrisbrodersen.de">Morris Brodersen</a>
VANILLA TODO &copy; 2020&ndash;2024 <a href="https://morrisbrodersen.de">Morris Brodersen</a>
&mdash; A case study on viable techniques for vanilla web development.
<a href="https://github.com/morris/vanilla-todo">About →</a>
</p>
@@ -47,7 +47,6 @@ export function TodoApp(el) {
el.querySelectorAll('.app-collapsible').forEach(AppCollapsible);
el.querySelectorAll('.app-icon').forEach(AppIcon);
el.querySelectorAll('.app-fps').forEach(AppFps);
TodoFrameDays(el.querySelector('.todo-frame.-days'));
TodoFrameCustom(el.querySelector('.todo-frame.-custom'));