MCPcopy Index your code
hub / github.com/callstack/agent-device / analyzeScrollEdgeState

Function analyzeScrollEdgeState

src/utils/scroll-edge-state.ts:33–66  ·  view source on GitHub ↗
(
  inputNodes: readonly (RawSnapshotNode | SnapshotNode)[] | undefined,
  edge: ScrollEdge,
  target: ScrollEdgeTarget = {},
)

Source from the content-addressed store, hash-verified

31const SCROLL_SIGNATURE_RECT_PRECISION = 1;
32
33function analyzeScrollEdgeState(
34 inputNodes: readonly (RawSnapshotNode | SnapshotNode)[] | undefined,
35 edge: ScrollEdge,
36 target: ScrollEdgeTarget = {},
37): ScrollEdgeState {
38 const nodes = ensureSnapshotNodes(inputNodes ?? []);
39 if (nodes.length === 0) {
40 return {
41 canScroll: false,
42 emptySnapshot: true,
43 signature: '',
44 };
45 }
46
47 const hiddenHints = deriveMobileSnapshotHiddenContentHints(nodes);
48 const container = selectScrollContainer(nodes, hiddenHints, edge, target);
49 const signatureNodes = container ? collectSubtreeNodes(nodes, container.index) : nodes;
50 const signature = buildScrollStateSignature(signatureNodes);
51 if (!container) {
52 return {
53 canScroll: false,
54 emptySnapshot: false,
55 signature,
56 };
57 }
58
59 const canScroll = hasHiddenContentAtEdge(container, hiddenHints.get(container.index), edge);
60 return {
61 canScroll,
62 emptySnapshot: false,
63 signature,
64 scope: buildScrollContainerScope(container),
65 };
66}
67
68export async function captureScrollEdgeState(params: {
69 edge: ScrollEdge;

Callers 1

captureScrollEdgeStateFunction · 0.85

Calls 8

ensureSnapshotNodesFunction · 0.85
selectScrollContainerFunction · 0.85
collectSubtreeNodesFunction · 0.85
hasHiddenContentAtEdgeFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected