Kaynağa Gözat

fix: keep the glass lens clean on every iOS browser

WebKit draws the lens's refraction filter out of place: a dark disc
slides off to one side and is cut square by the filter's box. The filter
is now kept from every WebKit browser by user agent as well (every iOS
browser is WebKit, whatever brands it reports), the lens clips to a
circle with clip-path so nothing in it can paint outside, and nothing
in its copy of the card gets a compositing layer of its own. One shared
isWebKit check now serves the theme switch too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEPoSHwHCYMNpm2iKxY9hL
Claude 1 ay önce
ebeveyn
işleme
b50a011d10

+ 1 - 1
components/cards/hero-title.tsx

@@ -516,7 +516,7 @@ export function HeroTitle() {
           />
         )}
         <div
-          className="absolute inset-0 overflow-hidden rounded-full bg-[#eff4fa] dark:bg-[#18212b]"
+          className="absolute inset-0 overflow-hidden rounded-full bg-[#eff4fa] [clip-path:circle(50%)] dark:bg-[#18212b]"
           style={{ filter: map ? `url(#${FILTER_ID})` : undefined }}
         >
           {/* Filled with a copy of the card from the effect; React keeps it empty. */}

+ 7 - 1
components/glass/displacement.ts

@@ -1,3 +1,5 @@
+import { isWebKit } from "@/lib/utils";
+
 /**
  * Liquid glass optics.
  *
@@ -173,6 +175,8 @@ let refraction: boolean | undefined;
 /**
  * Only Chromium renders SVG filters inside backdrop-filter. Firefox parses
  * them and then draws nothing, so feature detection can't be trusted here.
+ * WebKit draws the displacement out of place, so iOS browsers never get it,
+ * whatever brands they report.
  */
 export function supportsBackdropRefraction() {
   if (refraction !== undefined) return refraction;
@@ -180,7 +184,9 @@ export function supportsBackdropRefraction() {
     userAgentData?: { brands?: { brand: string }[] };
   };
 
-  refraction = !!nav.userAgentData?.brands?.some((b) => b.brand === "Chromium");
+  refraction =
+    !isWebKit() &&
+    !!nav.userAgentData?.brands?.some((b) => b.brand === "Chromium");
 
   return refraction;
 }

+ 2 - 6
lib/theme-transition.ts

@@ -2,7 +2,7 @@
 
 import { flushSync } from "react-dom";
 
-import { prefersReducedMotion } from "@/lib/utils";
+import { isWebKit, prefersReducedMotion } from "@/lib/utils";
 
 type ViewTransitionDoc = Document & {
   startViewTransition?: (update: () => void) => { ready: Promise<void> };
@@ -13,11 +13,7 @@ type ViewTransitionDoc = Document & {
  * without backdrop blur, so the glass nav and cards turned clear for the
  * length of the reveal and flashed back. There the theme switches at once.
  */
-const snapshotsDropGlass = () => {
-  const ua = navigator.userAgent;
-
-  return /AppleWebKit/.test(ua) && !/(Chrome|Chromium|Edg|OPR)\//.test(ua);
-};
+const snapshotsDropGlass = isWebKit;
 
 /**
  * Switches the theme with a circular reveal that grows from `origin`

+ 7 - 0
lib/utils.ts

@@ -8,6 +8,13 @@ export const prefersReducedMotion = () =>
   typeof window !== "undefined" &&
   window.matchMedia("(prefers-reduced-motion: reduce)").matches;
 
+/** WebKit proper: Safari, and every browser on iOS (Chrome there included). */
+export const isWebKit = () => {
+  const ua = navigator.userAgent;
+
+  return /AppleWebKit/.test(ua) && !/(Chrome|Chromium|Edg|OPR)\//.test(ua);
+};
+
 export const hasFinePointer = () =>
   typeof window !== "undefined" &&
   window.matchMedia("(hover: hover) and (pointer: fine)").matches;

+ 6 - 0
styles/globals.css

@@ -697,6 +697,12 @@ html.ff {
     transform-style: flat !important;
   }
 
+  [data-clone] * {
+    -webkit-backface-visibility: visible !important;
+    backface-visibility: visible !important;
+    will-change: auto !important;
+  }
+
   :is(a, button).lg {
     transition: scale var(--dur-wobble) var(--ease-wobble);
   }