Skip to content

Commit 0392aee

Browse files
committed
Adjust aspect ratio of "x ray" viewport to the same as the window
1 parent 3a0ab8a commit 0392aee

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTab.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,23 @@
106106
overflow: auto;
107107
}
108108

109+
.RectsBox {
110+
position: relative;
111+
flex-grow: 1;
112+
background: var(--color-border);
113+
}
114+
109115
.Rects {
116+
max-width: 100%;
117+
max-height: 100%;
118+
width: auto;
119+
height: auto;
120+
margin: auto;
121+
position: absolute;
122+
inset: 0;
110123
padding: 0.25rem;
111-
flex-grow: 1;
112124
overflow: auto;
125+
background-color: var(--color-background);
113126
}
114127

115128
.SuspenseTreeViewHeader {

packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTab.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
useRef,
1717
Fragment,
1818
} from 'react';
19+
import { flushSync } from 'react-dom';
1920

2021
import {
2122
localStorageGetItem,
@@ -186,6 +187,9 @@ function SynchronizedScrollContainer({
186187
if (element === null) {
187188
return;
188189
}
190+
// Mirror the viewport aspect ratio of the real window.
191+
const viewportAspectRatio = (right - left) / (bottom - top);
192+
element.style.aspectRatio = viewportAspectRatio;
189193
const scale = scaleRef.current / element.clientWidth;
190194
const targetLeft = Math.round(left / scale);
191195
const targetTop = Math.round(top / scale);
@@ -503,11 +507,13 @@ function SuspenseTab(_: {}) {
503507
orientation="horizontal"
504508
/>
505509
</header>
506-
<SynchronizedScrollContainer
507-
className={styles.Rects}
508-
scaleRef={scaleRef}>
509-
<SuspenseRects scaleRef={scaleRef} />
510-
</SynchronizedScrollContainer>
510+
<div className={styles.RectsBox}>
511+
<SynchronizedScrollContainer
512+
className={styles.Rects}
513+
scaleRef={scaleRef}>
514+
<SuspenseRects scaleRef={scaleRef} />
515+
</SynchronizedScrollContainer>
516+
</div>
511517
<footer className={styles.SuspenseTreeViewFooter}>
512518
<SuspenseTimeline />
513519
<div className={styles.SuspenseTreeViewFooterButtons}>

0 commit comments

Comments
 (0)