Fix iOS end-snap drift in filters carousel by using vi instead of cqw #2360
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
On the homepage Backdrop filters carousel, the last card (e.g.,
sepia
) ends up horizontally offset to the right on real iOS devices (Safari and Chrome). Chrome DevTools mobile emulation does not reproduce it. I noticed this while working on the tooltip PR.Proof
Repro
Minimal Fix (tested hotfix)
Rationale: In this full-bleed section,
50cqw ≈ 50vi
. Swapping tovi
avoids the container-unit code path that exhibits end-snap bias on iOS while keeping identical layout intent.Explanation
cqw
) for spacer math at the ends;cqw
= 1% of the query container’s width. MDN Web Docs50cqw
≈50vi
(viewport inline size).vi
is the writing-mode-aware "viewport width" (LTR pages:vi === vw
).scroll-padding
(orscroll-padding-inline
) is spec-intended and used during scroll snap and scroll-into-view operations. MDN Web Docscqw
→vi
removed the offset on real devices (no other changes). This suggests the issue is tied to container-unit rounding + end snap behavior, not content layout.Follow-up (separate PR if desired; not included here)
scroll-padding-inline: calc(50vi - var(--size)/2);
node.scrollIntoView({ inline: 'center', block: 'nearest' });