You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: clarify measurement, media handling, and edge cases in README
- Replace generic measurement blurb with wrapper-based measurement description
- Add media-aware re-measure behavior and auto-prune of trailing empty nodes
- Introduce "Edge Cases Covered" section
- Expand "How It Works" to mention re-parenting into a wrapper and media event sampling
Copy file name to clipboardExpand all lines: README.md
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,8 +14,10 @@ React Native WebView that auto-sizes to match its HTML content—whether you loa
14
14
15
15
## ✨ Highlights
16
16
17
-
- 📐 Auto-measures rendered HTML height on every DOM mutation or resize.
17
+
- 📐 Wrapper-based measurement keeps the WebView content in a dedicated container, so height always reflects the real DOM footprint.
18
18
- 🚀 Modern pipeline powered by `ResizeObserver`, `MutationObserver`, `visualViewport`, and font-load events with graceful fallbacks.
19
+
- 🖼 Media aware: images, iframes, and videos schedule immediate + next-frame re-measures as soon as they finish loading.
20
+
- 🧼 Auto-prunes trailing `<br>`/empty `<p>` tags that CMS editors often append, eliminating phantom spacing.
19
21
- 🧵 Keeps the WebView scroll-disabled so outer `ScrollView`s and gesture handlers stay silky smooth.
20
22
- 🎨 Transparent background by default; style the container however you like.
21
23
- ⚙️ Friendly API with `minHeight`, `containerStyle`, and `onHeightChange` callbacks.
@@ -85,9 +87,16 @@ The example showcases:
85
87
> [!NOTE]
86
88
> 🧩 `scrollEnabled` defaults to `false` so sizing remains deterministic. Only enable it if the WebView should manage its own scroll.
87
89
90
+
## 🧩 Edge Cases Covered
91
+
92
+
- Trailing `<br>` and empty `<p>` tags are stripped automatically so CMS exports don’t leave phantom padding.
93
+
- Images, iframes, and videos reschedule measurements the moment they finish loading—perfect for hero images at the end of an article.
94
+
- Wrapper rebuild + fallback timers keep measurements stable even if the remote page rewrites the entire DOM after load.
95
+
88
96
## 🧠 How It Works
89
97
90
-
- Injected bridge observes DOM mutations, layout changes, font loads, and viewport shifts.
98
+
- Injected bridge re-parents all body children into a dedicated wrapper, trims trailing blanks, and observes DOM mutations, layout changes, font loads, and viewport shifts.
99
+
- Media events (images / iframes / video) trigger immediate + next-frame samples so late assets still report accurate heights.
91
100
- Height calculations are debounced via `requestAnimationFrame` and a short idle timer to prevent resize storms.
92
101
- Measurements arrive through `postMessage`, then `useAutoHeight` coalesces them into a single render per frame.
93
102
- Package exports the bridge, hook, and helpers individually, making it easy to build bespoke wrappers when needed.
0 commit comments