patx/afterdarklabs

fix mobile cta reveal

Commit e5f2521 · patx · 2026-09-04T19:58:09-04:00

Changeset
e5f25218be84037ad26a7a9c2e20179da523c738
Parents
07f7527f55ca7a4175195d1b8cd88cbc5edf879c

View source at this commit

Comments

No comments yet.

Log in to comment

Diff

diff --git a/docs/index.html b/docs/index.html
index 7d22a64..ce335cc 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1473,8 +1473,11 @@
                 closingStatement.classList.remove('is-motion-ready');
 
                 const statementTop = closingStatement.getBoundingClientRect().top + window.scrollY;
-                // Match the layout viewport that bounds window.scrollY, including while zoomed.
-                const viewportHeight = document.documentElement.clientHeight || window.innerHeight;
+                const visualViewport = window.visualViewport;
+                // Browser chrome changes only the visual height; pinch zoom changes its width too.
+                const viewportHeight = visualViewport && visualViewport.width >= document.documentElement.clientWidth - 1
+                    ? visualViewport.height
+                    : document.documentElement.clientHeight || window.innerHeight;
                 const statementHeight = closingStatement.offsetHeight;
                 const maximumScroll = Math.max(0, document.documentElement.scrollHeight - viewportHeight);
                 revealStart = Math.min(maximumScroll, statementTop - viewportHeight + statementHeight * 0.05);