v3.0.4 – Adaptive Frame of Stillness
Dynamic iframe resizing via postMessage handshake. Perfect centering restored. Infinite recursion made visible.
This commit is contained in:
parent
3a1aa160a8
commit
e74d6de19d
3 changed files with 54 additions and 31 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "the-fold-within",
|
"name": "the-fold-within",
|
||||||
"version": "3.0.3",
|
"version": "3.0.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pdf-parse": "^1.1.1"
|
"pdf-parse": "^1.1.1"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -265,33 +265,48 @@ function renderIframe(rel) {
|
||||||
const doc = iframe.contentDocument;
|
const doc = iframe.contentDocument;
|
||||||
const style = doc.createElement("style");
|
const style = doc.createElement("style");
|
||||||
style.textContent = `
|
style.textContent = `
|
||||||
html,body{
|
html,body {
|
||||||
background:#0b0b0b;
|
background:#0b0b0b;
|
||||||
color:#e6e3d7;
|
color:#e6e3d7;
|
||||||
font-family:Inter,sans-serif;
|
font-family:Inter,sans-serif;
|
||||||
margin:0;
|
margin:0;
|
||||||
padding:3vh 6vw;
|
padding:3vh 6vw;
|
||||||
line-height:1.8;
|
line-height:1.8;
|
||||||
}
|
}
|
||||||
body{
|
body {
|
||||||
display:flex;
|
display:flex;
|
||||||
flex-direction:column;
|
flex-direction:column;
|
||||||
align-items:center;
|
align-items:center;
|
||||||
justify-content:flex-start;
|
justify-content:flex-start;
|
||||||
min-height:100vh;
|
min-height:100vh;
|
||||||
}
|
}
|
||||||
*{
|
* {
|
||||||
max-width:960px;
|
max-width:960px;
|
||||||
width:100%;
|
width:100%;
|
||||||
}
|
}
|
||||||
img,video,iframe{
|
img,video,iframe {
|
||||||
max-width:100%;
|
max-width:100%;
|
||||||
height:auto;
|
height:auto;
|
||||||
border-radius:8px;
|
border-radius:8px;
|
||||||
}
|
}
|
||||||
`;
|
/* remove internal scrollbars */
|
||||||
|
html { overflow:hidden; }
|
||||||
|
`;
|
||||||
doc.head.appendChild(style);
|
doc.head.appendChild(style);
|
||||||
} catch {}
|
|
||||||
|
// Inject auto-height script
|
||||||
|
const script = doc.createElement("script");
|
||||||
|
script.textContent = `
|
||||||
|
function sendHeight() {
|
||||||
|
window.parent.postMessage({ type: 'resizeFrame', height: document.body.scrollHeight }, '*');
|
||||||
|
}
|
||||||
|
new ResizeObserver(sendHeight).observe(document.body);
|
||||||
|
window.addEventListener('load', sendHeight);
|
||||||
|
`;
|
||||||
|
doc.body.appendChild(script);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("iframe load error", e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,4 +321,13 @@ function renderDefault() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener("message", e => {
|
||||||
|
if (e.data?.type === "resizeFrame") {
|
||||||
|
const iframe = document.querySelector("iframe[src*='" + location.hash.replace(/^#\//, "") + "']");
|
||||||
|
if (iframe) {
|
||||||
|
iframe.style.height = e.data.height + "px";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
|
||||||
|
|
@ -212,22 +212,21 @@ body.sidebar-open #sidebar { transform: translateX(0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
.viewer iframe {
|
.viewer iframe {
|
||||||
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 960px;
|
max-width: 960px;
|
||||||
height: calc(100vh - var(--topbar-h) - var(--subnav-h) - 120px);
|
|
||||||
min-height: 500px;
|
min-height: 500px;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: var(--radius);
|
border-radius: var(--radius);
|
||||||
background: #0b0b0b;
|
background: #0b0b0b;
|
||||||
box-shadow: 0 0 30px rgba(0,0,0,0.6);
|
box-shadow: 0 0 30px rgba(0,0,0,0.6);
|
||||||
margin: 0 auto;
|
margin: 0 auto 3rem auto;
|
||||||
transition: all .4s ease;
|
transition: height .4s ease, transform .4s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.viewer iframe {
|
.viewer iframe {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
height: calc(100vh - var(--topbar-h) - var(--subnav-h) - 80px);
|
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue