MCPcopy
hub / github.com/vuejs/core / hydrateOnVisible

Function hydrateOnVisible

packages/runtime-core/src/hydrationStrategies.ts:48–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46export 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
69export const hydrateOnMediaQuery: HydrationStrategyFactory<string> =
70 query => hydrate => {

Callers

nothing calls this directly

Calls 3

hydrateFunction · 0.85
forEachFunction · 0.50

Tested by

no test coverage detected