( target: any, params: JSONObject, relative: boolean, )
| 2429 | } |
| 2430 | |
| 2431 | function 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 | |
| 2456 | function encodeValue(value: any): unknown { |
| 2457 | if (value == null) { |
no test coverage detected