| 46 | export const hydrateOnVisible: HydrationStrategyFactory< |
| 47 | IntersectionObserverInit |
| 48 | > = opts => (hydrate, forEach) => { |
| 49 | const ob = new IntersectionObserver(entries => { |
| 50 | for (const e of entries) { |
| 51 | if (!e.isIntersecting) continue |
| 52 | ob.disconnect() |
| 53 | hydrate() |
| 54 | break |
| 55 | } |
| 56 | }, opts) |
| 57 | forEach(el => { |
| 58 | if (!(el instanceof Element)) return |
| 59 | if (elementIsVisibleInViewport(el)) { |
| 60 | hydrate() |
| 61 | ob.disconnect() |
| 62 | return false |
| 63 | } |
| 64 | ob.observe(el) |
| 65 | }) |
| 66 | return () => ob.disconnect() |
| 67 | } |
| 68 | |
| 69 | export const hydrateOnMediaQuery: HydrationStrategyFactory<string> = |
| 70 | query => hydrate => { |
nothing calls this directly
no test coverage detected