MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / scroll

Function scroll

packages/nativescript-inspector/src/index.ts:2431–2454  ·  view source on GitHub ↗
(
  target: any,
  params: JSONObject,
  relative: boolean,
)

Source from the content-addressed store, hash-verified

2429}
2430
2431function scroll(
2432 target: any,
2433 params: JSONObject,
2434 relative: boolean,
2435): JSONObject {
2436 if (!isKindOf(target, "UIScrollView")) {
2437 throw new InspectorFailure(
2438 -32011,
2439 "scroll actions are only supported for UIScrollView.",
2440 );
2441 }
2442 const current = read(target, "contentOffset");
2443 const x = numberValue(params.x);
2444 const y = numberValue(params.y);
2445 const next = relative
2446 ? CGPointMake(numberValue(current.x) + x, numberValue(current.y) + y)
2447 : CGPointMake(x, y);
2448 target.setContentOffsetAnimated(next, Boolean(params.animated));
2449 return {
2450 ok: true,
2451 action: relative ? "scrollBy" : "scrollTo",
2452 contentOffset: pointValue(read(target, "contentOffset")),
2453 };
2454}
2455
2456function encodeValue(value: any): unknown {
2457 if (value == null) {

Callers 1

performMethod · 0.85

Calls 4

isKindOfFunction · 0.85
readFunction · 0.85
numberValueFunction · 0.85
pointValueFunction · 0.85

Tested by

no test coverage detected