MCPcopy
hub / github.com/callstack/react-native-testing-library / tryGetContentOffset

Function tryGetContentOffset

src/fire-event.ts:194–212  ·  view source on GitHub ↗
(event: unknown)

Source from the content-addressed store, hash-verified

192}
193
194function tryGetContentOffset(event: unknown): Point | null {
195 try {
196 // @ts-expect-error: try to extract contentOffset from the event value
197 const contentOffset = event?.nativeEvent?.contentOffset;
198 const x = contentOffset?.x;
199 const y = contentOffset?.y;
200
201 if (typeof x === 'number' || typeof y === 'number') {
202 return {
203 x: Number.isFinite(x) ? x : 0,
204 y: Number.isFinite(y) ? y : 0,
205 };
206 }
207 } catch {
208 // Do nothing
209 }
210
211 return null;
212}
213
214function mergeEventProps(target: Record<string, unknown>, source: Record<string, unknown>) {
215 for (const key of Object.keys(source)) {

Callers 1

setNativeStateIfNeededFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…