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

Function handleScrollCommand

src/core/dispatch-interactions.ts:745–771  ·  view source on GitHub ↗
(
  interactor: Interactor,
  positionals: string[],
  context: DispatchContext | undefined,
)

Source from the content-addressed store, hash-verified

743}
744
745export async function handleScrollCommand(
746 interactor: Interactor,
747 positionals: string[],
748 context: DispatchContext | undefined,
749): Promise<Record<string, unknown>> {
750 const directionInput = positionals[0];
751 const amount = positionals[1] ? Number(positionals[1]) : undefined;
752 const pixels = context?.pixels;
753 const durationMs = context?.durationMs;
754 if (!directionInput) throw new AppError('INVALID_ARGS', 'scroll requires direction');
755 assertScrollCommandInputs(amount, pixels, durationMs);
756
757 const target = parseScrollTarget(directionInput);
758 const options = { amount, pixels, durationMs };
759 const { interactionResult, completedPasses } = await runDispatchedScroll(
760 interactor,
761 context,
762 target,
763 options,
764 );
765
766 const result = buildDispatchedScrollResult(target, options, completedPasses, interactionResult);
767 return withSuccessText(
768 result,
769 formatScrollEdgeMessage(target.direction, target.edge, completedPasses, amount, pixels),
770 );
771}
772
773function assertScrollCommandInputs(
774 amount: number | undefined,

Callers 2

dispatch.tsFile · 0.90

Calls 6

withSuccessTextFunction · 0.90
formatScrollEdgeMessageFunction · 0.90
parseScrollTargetFunction · 0.85
runDispatchedScrollFunction · 0.85

Tested by

no test coverage detected