Skip to content

Commit

Permalink
fix(devtools): perf optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
artalar committed Oct 14, 2024
1 parent 24d6146 commit 042a77c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/devtools/src/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,15 @@ export const Graph = ({ clientCtx, getColor, width, height }: Props) => {
insert(patch)
}

const isBottom =
listEl.parentElement!.scrollHeight - listEl.parentElement!.scrollTop < listEl.parentElement!.clientHeight + 10
if (isBottom) {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
const isBottom =
listEl.parentElement!.scrollHeight - listEl.parentElement!.scrollTop <
listEl.parentElement!.clientHeight + 10

if (isBottom) {
listEl.parentElement!.scrollTop = listEl.parentElement!.scrollHeight
})
}
}
})
})
})

Expand All @@ -301,6 +303,7 @@ export const Graph = ({ clientCtx, getColor, width, height }: Props) => {
top: 0;
left: 68px;
pointer-events: var(--pe);
will-change: height;
`}
>
{lines}
Expand All @@ -312,6 +315,7 @@ export const Graph = ({ clientCtx, getColor, width, height }: Props) => {
ref={subscribe}
css={`
padding: 0;
content-visibility: auto;
`}
>
{list}
Expand Down
1 change: 1 addition & 0 deletions packages/devtools/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export const _connectDevtools = async (
height: var(--height);
z-index: ${MAX_Z};
background: var(--devtools-bg);
will-change: width, height;
`}
css:devtools-bg="hsl(244deg 20% 90%)"
css:width={width}
Expand Down

0 comments on commit 042a77c

Please sign in to comment.