MCPcopy Create free account
hub / github.com/Effect-TS/effect / moved

Function moved

packages/ui/native/src/kit/VirtualList.ts:354–375  ·  view source on GitHub ↗
(
  model: Model,
  props: VirtualListProps,
  kept = false
)

Source from the content-addressed store, hash-verified

352// After a content change, the stored offset can precede native's anchor
353// adjustment. Keep the same visible item until the next scroll event.
354const moved = (
355 model: Model,
356 props: VirtualListProps,
357 kept = false
358): Virtualizer.Updated<Model> => {
359 if (model.viewport === 0) return { model, events: [] }
360 const origin = originOf(model, props)
361 return Virtualizer.update(
362 model,
363 props,
364 Virtualizer.Message.MovedViewport({
365 start: kept ? model.scrollOffset - origin : startOf(model, props),
366 height: model.viewport,
367 anchor: kept && anchoredOf(props) ? model.position : null,
368 atStart: model.scrollOffset <= Virtualizer.edgeThreshold,
369 atEnd: atEndOf(model, props),
370 overflowing: model.content > model.viewport + 0.5,
371 length: Math.max(0, model.content - origin),
372 scrolled: null
373 })
374 )
375}
376
377// The scroll the model asks for: to a waiting request's target, or to the
378// end when the content grew under a list that follows it.

Callers 1

VirtualList.tsFile · 0.70

Calls 5

anchoredOfFunction · 0.85
atEndOfFunction · 0.85
originOfFunction · 0.70
startOfFunction · 0.70
updateMethod · 0.65

Tested by

no test coverage detected