Skip to content

Commit ea80e1d

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

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-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: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ function SynchronizedScrollContainer({
186186
if (element === null) {
187187
return;
188188
}
189+
// Mirror the viewport aspect ratio of the real window.
190+
const viewportAspectRatio = (right - left) / (bottom - top);
191+
element.style.aspectRatio = viewportAspectRatio;
189192
const scale = scaleRef.current / element.clientWidth;
190193
const targetLeft = Math.round(left / scale);
191194
const targetTop = Math.round(top / scale);
@@ -503,11 +506,13 @@ function SuspenseTab(_: {}) {
503506
orientation="horizontal"
504507
/>
505508
</header>
506-
<SynchronizedScrollContainer
507-
className={styles.Rects}
508-
scaleRef={scaleRef}>
509-
<SuspenseRects scaleRef={scaleRef} />
510-
</SynchronizedScrollContainer>
509+
<div className={styles.RectsBox}>
510+
<SynchronizedScrollContainer
511+
className={styles.Rects}
512+
scaleRef={scaleRef}>
513+
<SuspenseRects scaleRef={scaleRef} />
514+
</SynchronizedScrollContainer>
515+
</div>
511516
<footer className={styles.SuspenseTreeViewFooter}>
512517
<SuspenseTimeline />
513518
<div className={styles.SuspenseTreeViewFooterButtons}>

0 commit comments

Comments
 (0)