Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Simplify iOS viewport height polyfill to avoid resize jank

Maximilian Roos72164651b8b5
diff --git a/docs/sass/custom.scss b/docs/sass/custom.scss
index 2a536db0c..3fdbc8c07 100644
--- a/docs/sass/custom.scss
+++ b/docs/sass/custom.scss
@@ -9,8 +9,6 @@ html {
// Reserve scrollbar space to prevent layout shift when navigating
// Browser support: Safari 17+, Chrome 94+, Firefox 97+. Graceful degradation.
scrollbar-gutter: stable;
- // Enable -webkit-fill-available to work correctly for child elements on iOS
- height: -webkit-fill-available;
}
// ============================================================================
@@ -133,24 +131,6 @@ header {
z-index: 200;
pointer-events: none;
}
-
- // iOS WebKit viewport height fix: -webkit-fill-available is stable
- // against browser chrome animation, unlike svh/lvh which may jank on
- // Firefox iOS and Chrome iOS due to missing WebKit viewport inset APIs.
- // See: https://github.com/mozilla-mobile/firefox-ios/issues/11574
- body {
- min-height: -webkit-fill-available;
- }
-
- .hero {
- // Use string interpolation to bypass SCSS calc() parsing
- height: #{"calc(-webkit-fill-available - var(--wt-header-height) - env(safe-area-inset-top, 0px))"} !important;
- max-height: #{"calc(-webkit-fill-available - var(--wt-header-height) - env(safe-area-inset-top, 0px))"} !important;
- }
-
- .mobile-menu {
- height: #{"calc(-webkit-fill-available - var(--wt-header-height) - env(safe-area-inset-top, 0px))"};
- }
}
.logo {
diff --git a/docs/templates/base.html b/docs/templates/base.html
index 53cd9a546..0944b74db 100644
--- a/docs/templates/base.html
+++ b/docs/templates/base.html
@@ -16,47 +16,34 @@
{# _variables.html is already included by the theme at line 12 of juice/templates/index.html #}
{# Zola resolves it to our custom templates/_variables.html, so no need to include it again #}
<script>
-// iOS viewport height polyfill: svh/lvh are broken on Firefox iOS and Chrome iOS
-// due to missing minimumViewportInset/maximumViewportInset WebKit APIs.
-// This sets a stable --vh-full CSS variable by tracking the minimum viewport height.
+// iOS viewport height fix: Capture a STABLE height once on page load.
+// Do NOT update on resize/scroll - that's what causes the jank!
+// On Firefox iOS and Chrome iOS, svh/lvh behave like dvh due to missing
+// minimumViewportInset/maximumViewportInset WebKit APIs.
// See: https://github.com/mozilla-mobile/firefox-ios/issues/11574
(function() {
- // Only run on iOS WebKit browsers (Safari, Chrome iOS, Firefox iOS, in-app webviews)
+ // Only run on iOS WebKit browsers
var isIOS = /iP(hone|ad|od)/.test(navigator.platform) ||
(/Macintosh/.test(navigator.userAgent) && 'ontouchend' in document);
if (!isIOS) return;
- var raf, lastHeight;
-
- function setViewportHeight() {
- // Use the smallest of available height measurements to approximate "small viewport"
- var c1 = window.innerHeight;
- var c2 = document.documentElement.clientHeight;
- var c3 = (window.visualViewport && window.visualViewport.height) || c1;
- var h = Math.min(c1 || Infinity, c2 || Infinity, c3 || Infinity);
- if (h && h !== lastHeight) {
- lastHeight = h;
- document.documentElement.style.setProperty('--vh-full', h + 'px');
- }
- }
-
- function schedule() {
- if (raf) return;
- raf = requestAnimationFrame(function() {
- raf = null;
- setViewportHeight();
- });
+ // Capture initial viewport height ONCE (with browser chrome visible)
+ // and use it as a stable value. Never update on resize.
+ var h = window.innerHeight;
+ if (h) {
+ document.documentElement.style.setProperty('--vh-full', h + 'px');
}
- // Set initial value immediately
- setViewportHeight();
-
- // Update on relevant events (passive for performance)
- window.addEventListener('resize', schedule, { passive: true });
- window.addEventListener('orientationchange', schedule, { passive: true });
- if (window.visualViewport) {
- window.visualViewport.addEventListener('resize', schedule, { passive: true });
- }
+ // Only update on orientation change (actual device rotation)
+ window.addEventListener('orientationchange', function() {
+ // Small delay to let the new orientation settle
+ setTimeout(function() {
+ var newH = window.innerHeight;
+ if (newH) {
+ document.documentElement.style.setProperty('--vh-full', newH + 'px');
+ }
+ }, 100);
+ });
})();
</script>
<meta name="view-transition" content="same-origin">