# Business Logic Model - Unit 2: Display fallbacks Unit 2 of the feature "prerendering": fade-in, no JavaScript, first photo (FR-PR-09 to 13, FR-PR-21; D6 to D9). It builds on unit 1 (hydration rule BR-HYD-01: the first browser render equals the HTML). Rules: [business-rules.md](business-rules.md). Data: [domain-entities.md](domain-entities.md). Components: [frontend-components.md](frontend-components.md). Everything here was checked against `web/src`, the built `web/dist/client`, the Lighthouse reports of the measurement at the gate (`after` and `revealvisible`, mobile and desktop) and a real Chrome driven by Playwright against the local preview server, on 2026-10-31. No application code was changed. ## 1. Reveal ### 1.1 Lifetime of one `Reveal` ```mermaid graph TD Server["Prerender: settled, visible"] --> Html["HTML on screen, content visible"] Html --> Hydrate["Hydrating render: settled, same markup"] Hydrate --> Layout["Layout effect before paint: measure top edge"] Layout --> Test{"Top at or below innerHeight"} Test -->|"no"| Stay["Stays settled: no change at all"] Test -->|"yes"| Hide["Set hidden: opacity 0, no transition"] Hide --> Watch["Observer: threshold 0.12, margin 60 px"] Watch --> Fire["Intersected once"] Fire --> Fade["Revealed: fade 0.8 s after delay"] classDef build fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000; classDef state fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000; classDef choice fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; class Server,Html,Hydrate build; class Layout,Watch,Fire,Hide state; class Stay,Fade state; class Test choice; ``` Text alternative: the HTML and hydrating render are visible; a layout effect hides only elements wholly below the viewport before the next paint, and an observer reveals each once. ### 1.2 Why the layout effect and why `top >= innerHeight` - **Layout effect, not a passive effect.** A passive effect runs after the browser painted. An element in the 60 px band at the bottom of the screen would be painted visible from the HTML, then hidden, which is the flash FR-PR-09 forbids. A layout effect runs after React committed the hydrated tree and before the next paint, and a state change inside it is applied synchronously before that paint. No `useLayoutEffect` exists in `src` today; React 19.3 does not warn for it while prerendering. - **Reads before writes.** Every `Reveal` in the commit reads its rectangle in its own layout effect; the state updates are applied after all effects ran. The browser lays out once, not once per `Reveal`. - **The test is the viewport edge, not the 60 px line.** The trigger line (`rootMargin` bottom -60 px) is how late the fade starts while scrolling. At load the question is "was this painted on screen". Only an element that starts at or below the bottom edge was not. - **No transition for the hide.** The hidden style sets `transition: none`. A transition is taken from the style after the change, so the step from settled to hidden does not animate. The transition properties exist only in the revealed style. - **Reduced motion is read directly.** Chakra's `useMediaQuery` (BR-HYD-07) still returns its server-safe `false` in that same layout effect, because its own effect has not run. Reading `matchMedia` in the effect avoids a hide followed by an animated reveal. ### 1.3 Anything that breaks All 21 call sites keep their props. What each does under the new rule at 412 x 823 and 1350 x 940 (probe of `data-reveal` and tops, dist build): | Call site (file, count) | Wraps | Effect | |---|---|---| | `home/IntroGallery` (2), `home/Pricing` (2), `home/Testimonials` (2), `home/ContactSection` (2), `InstagramGrid` (2) | Headings, photo lists, cards | First `Reveal` of `/` is at top 919 px at 412 x 823: all hidden at load, fade on scroll, as now. At 1350 x 940 the first ones are in view and stay. `Pricing` stagger (`delay`) only shows on scroll (BR-RVL-06). | | `MediaText` (2: photo and text) | Photo column and text column of `/over-mij`, `/soorten-fotoshoots`, shoot pages | In view at the top of these pages: visible at once. Before: 1.0 s after the first paint (observed LCP 977 to 1047 ms at 412 x 823). | | `PhotoMosaic` (1, `as="li"` with `delay`), `PhotoDuo` (1), `PortfolioGrid` (1), `ProcessTimeline` (1), `StoryBlocks` (1), `CallToAction` (1), `StorySection` (1), `routes/contact` (2) | Lists, grids, blocks | Same rule. `PortfolioGrid` is the tall one: see BR-RVL-13 and 1.4. `routes/contact` has one `Reveal` around `display: none` content from `lg` (zero rectangle, so it counts as in view and is settled). | | `data-reveal` consumers | `MediaText.test`, `ShootList.test`, `Reveal.test` use `closest('[data-reveal]')` only | Unchanged: the attribute stays, values `visible` and `hidden`. | | `IntersectionObserver` absent (jsdom, old browsers) | Whole site | Settled and visible (BR-RVL-08); the existing `Reveal.test` case stays. | | Tests with a fake observer (`useReveal.test`) | The hook | Five cases change (BR-DTS-01). No other test asserts hidden content. | ### 1.4 The `/portfolio` grid and an existing defect Measured in Chrome at 412 x 823 on the built page, 2 s after load: the grid wrapper of `/portfolio` (`top` 377, height 4537) was still `data-reveal="hidden"`. Its top part is on screen but 12 % of its height (544 px) never fits between the top of the grid and the 60 px line (386 px visible), so the observer never fires. The final screenshots of the Lighthouse reports (master and unit 1) show the same empty area under the filter row at 3 s. This is the behaviour on master too. The new rule makes the grid settled at load (BR-RVL-03), which fixes it for elements that start in view, and is also why `/portfolio` changes in the measurement (section 6). ### 1.5 Client navigation Option specified (provisional, O1): the same rule as on a first load; no `useHydrated` branch. - Why: FR-PR-09's reason is that visible content must never wait for an animation. One rule on both paths has no divergence to test, and the hydration rule (BR-HYD-01) is untouched. - What changes: today a page reached by client navigation fades in its first screen; after this unit its first screen is visible at once and only content below the fold fades on scroll. - Alternative: hide in the first render when `useHydrated()` is already `true` and let the observer reveal what is in view. It keeps the entrance fade, costs a second code path and a second set of tests, and holds back content in view for the length of the fade. ## 2. Images ### 2.1 What `DeferredImage` renders ```mermaid graph TD Props["DeferredImage props: image, near, style props"] --> First["img: no src until loaded, loading lazy, data-deferred"] Props --> Twin["noscript: img with src, alt, width, height, same style props"] First --> Phase{"Page loaded and near the viewport"} Phase -->|"yes"| SetSrc["Effect sets src, photo loads"] Phase -->|"no"| Empty["Stays empty, as in unit 1"] Twin --> NoJs{"Parser scripting enabled"} NoJs -->|"yes"| Text["Content is text: nothing fetched"] NoJs -->|"no"| Shown["Twin is an img: photo loads"] classDef comp fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000; classDef markup fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000; classDef choice fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; class Props comp; class First,Twin,SetSrc,Empty,Text,Shown markup; class Phase,NoJs choice; ``` Text alternative: DeferredImage renders its deferred image and a noscript twin; without scripting the twin shows the photo and the CSS hides the empty image. ### 2.2 Facts behind the design | Question | Answer | Evidence | |---|---|---| | What does the empty `` look like without JavaScript | A sized box (its CSS size) with Chrome's broken-image icon and the alt text inside; `complete` is `true`, `naturalWidth` 0 | Screenshot of `/soorten-fotoshoots` with JavaScript off and `Reveal` forced visible | | Is the twin double-displayed | Not when the empty image is `display: none` (BR-IMG-02); both have the same class so the twin has the same box | Class equality by construction; V-D2 | | Does the twin download with JavaScript on | No. `noscript` content is text; React 19.3 client does not render `noscript` children (`shouldSetTextContent` in `react-dom-client.production.js`) | Source | | Does the twin add a preload | No. `react-dom-server` skips the image preload when `tagScope & 1` (inside `noscript`) | Source, line 2135 ff. of `react-dom-server.node.production.js` | | Does the twin cause a hydration mismatch | No: children of `noscript` are not compared | Source; V-D1, V-D3 | | Lazy loading without JavaScript | Not honoured by Chrome; all twins load at once | BR-IMG-05 | ### 2.3 Every image path that depends on JavaScript `DeferredImage` (deferred `src`) is the only mechanism that withholds a photo from the HTML, besides the hero's later slides. All image-rendering components in `src` (grep of `DeferredImage` and `