mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-10 07:28:15 -05:00
viz: small profiler resizing improvements (#12026)
* switch to ResizeObserver * set a fixed size for device-list * less * height from devices * int * side rect, more const
This commit is contained in:
@@ -252,7 +252,7 @@
|
||||
}
|
||||
#device-list > div {
|
||||
min-height: 32px;
|
||||
max-width: 132px;
|
||||
width: 132px;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
white-space: nowrap;
|
||||
@@ -261,6 +261,9 @@
|
||||
#device-list > div:hover {
|
||||
background-color: rgba(20, 23, 35, 0.3);
|
||||
}
|
||||
#device-list {
|
||||
height: fit-content;
|
||||
}
|
||||
.raw-text {
|
||||
padding: 0 8px;
|
||||
width: 100%;
|
||||
|
||||
@@ -380,9 +380,9 @@ async function renderProfiler() {
|
||||
|
||||
function resize() {
|
||||
const profiler = document.querySelector(".profiler");
|
||||
// NOTE: use clientWidth to account for the scrollbar
|
||||
let [width, height] = [profiler.clientWidth, profiler.scrollHeight];
|
||||
width -= rect("#device-list").width+padding;
|
||||
const sideRect = rect("#device-list");
|
||||
const width = profiler.clientWidth-(sideRect.width+padding), height = Math.round(sideRect.height);
|
||||
if (canvas.width === width*dpr && canvas.height === height*dpr) return;
|
||||
canvas.width = width*dpr;
|
||||
canvas.height = height*dpr;
|
||||
canvas.style.height = `${height}px`;
|
||||
@@ -395,8 +395,7 @@ async function renderProfiler() {
|
||||
d3.select(canvas).call(canvasZoom);
|
||||
document.addEventListener("contextmenu", e => e.ctrlKey && e.preventDefault());
|
||||
|
||||
resize();
|
||||
window.addEventListener("resize", resize);
|
||||
new ResizeObserver(([e]) => e.contentRect.width > 0 && resize()).observe(profiler.node());
|
||||
|
||||
function findRectAtPosition(x, y) {
|
||||
const { top, left, width, height } = rect(canvas);
|
||||
|
||||
Reference in New Issue
Block a user