rosary: fix mystery image column clipping at edges
All checks were successful
CI / update (push) Successful in 1m26s
All checks were successful
CI / update (push) Successful in 1m26s
Use taller edge pads (100vh) for before/after targets so images don't peek at viewport top or bottom. Scroll to edge pads with zero offset so previous/next images hide fully behind the sticky header.
This commit is contained in:
@@ -424,13 +424,18 @@ function scrollMysteryImage(targetY, duration = 1200) {
|
||||
}
|
||||
|
||||
// Scroll the mystery image column to the relevant image
|
||||
const IMAGE_COL_HEADER_OFFSET = 6; // rem — keep images below the sticky header
|
||||
$effect(() => {
|
||||
if (!mysteryImageContainer || !hasMysteryImages) return;
|
||||
const targetName = getMysteryScrollTarget(activeSection);
|
||||
const targetEl = mysteryImageContainer.querySelector(`[data-target="${targetName}"]`);
|
||||
if (targetEl) {
|
||||
const padding = parseFloat(getComputedStyle(mysteryImageContainer).paddingTop) || 0;
|
||||
scrollMysteryImage(Math.max(0, targetEl.offsetTop - padding));
|
||||
const rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||
// Edge pads (before/after): scroll flush so previous image hides behind the header
|
||||
const offset = targetName === 'before' || targetName === 'after'
|
||||
? 0
|
||||
: rem * IMAGE_COL_HEADER_OFFSET;
|
||||
scrollMysteryImage(Math.max(0, targetEl.offsetTop - offset));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1414,7 +1419,6 @@ h1 {
|
||||
display: block;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
padding-top: 6rem;
|
||||
align-self: start;
|
||||
max-height: 100vh;
|
||||
overflow-y: auto;
|
||||
@@ -1427,6 +1431,10 @@ h1 {
|
||||
.mystery-image-pad {
|
||||
height: calc(100vh - 5rem);
|
||||
}
|
||||
.mystery-image-pad[data-target="before"],
|
||||
.mystery-image-pad[data-target="after"] {
|
||||
height: 100vh;
|
||||
}
|
||||
.mystery-image-column figure {
|
||||
margin: 0;
|
||||
margin-right: 2rem;
|
||||
|
||||
Reference in New Issue
Block a user