Skip to content

Commit 12432f8

Browse files
committed
Fix height not scaling on fixed size sketches
1 parent 39f1192 commit 12432f8

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/components/ScalingIframe/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ export const ScalingIframe = ({
2828
<iframe
2929
width={width}
3030
{...props}
31-
style={{ transform: `scale(${scale.toFixed(4)})`, transformOrigin: 'top left' }}
31+
style={{
32+
position: "absolute",
33+
top: 0,
34+
left: 0,
35+
transform: `scale(${scale.toFixed(4)})`,
36+
transformOrigin: "top left",
37+
}}
3238
ref={iframeRef}
3339
/>
3440
);

src/layouts/SketchLayout.astro

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,29 @@ const iframeTitle = `OpenProcessing Sketch: ${sketchInfo.title} by ${authorName}
6464
topic={"community"}
6565
>
6666
<div class="max-w-[767px]">
67-
{width ? (
68-
<div style={{ width: '100%', height: `${(heightOverWidth * 100).toFixed(4)}%`, overflow: 'hidden' }}>
67+
<div style={{
68+
position: 'relative',
69+
width: '100%',
70+
paddingBottom: `${(heightOverWidth * 100).toFixed(4)}%`,
71+
}}>
72+
{width ? (
6973
<ScalingIframe
7074
client:load
7175
src={makeSketchEmbedUrl(sketchInfo.visualID)}
7276
width={width}
7377
height={height}
7478
title={iframeTitle}
7579
/>
76-
</div>
77-
) : (
78-
<div style={{
79-
position: 'relative',
80-
width: '100%',
81-
paddingBottom: `${(heightOverWidth * 100).toFixed(4)}%`,
82-
}}>
80+
) : (
8381
<iframe
8482
src={makeSketchEmbedUrl(sketchInfo.visualID)}
8583
width="100%"
8684
height="100%"
8785
style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }}
8886
title={iframeTitle}
8987
/>
90-
</div>
91-
)}
88+
)}
89+
</div>
9290
<div class="py-md grid gap-y-sm md:gap-y-md">
9391
<LinkButton
9492
variant="code"

0 commit comments

Comments
 (0)