Skip to content

Commit 5e70234

Browse files
committed
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
1 parent 6de37d2 commit 5e70234

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ React Native WebView that auto-sizes to match its HTML content—whether you loa
1414
1515
## ✨ Highlights
1616

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.
1818
- 🚀 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.
1921
- 🧵 Keeps the WebView scroll-disabled so outer `ScrollView`s and gesture handlers stay silky smooth.
2022
- 🎨 Transparent background by default; style the container however you like.
2123
- ⚙️ Friendly API with `minHeight`, `containerStyle`, and `onHeightChange` callbacks.
@@ -85,9 +87,16 @@ The example showcases:
8587
> [!NOTE]
8688
> 🧩 `scrollEnabled` defaults to `false` so sizing remains deterministic. Only enable it if the WebView should manage its own scroll.
8789
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+
8896
## 🧠 How It Works
8997

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.
91100
- Height calculations are debounced via `requestAnimationFrame` and a short idle timer to prevent resize storms.
92101
- Measurements arrive through `postMessage`, then `useAutoHeight` coalesces them into a single render per frame.
93102
- Package exports the bridge, hook, and helpers individually, making it easy to build bespoke wrappers when needed.

0 commit comments

Comments
 (0)