ScrollMotion
What a Scroll or a List moves as it scrolls, every frame on the UI thread (docs/motion.md#motion-sources). Only the view writes them: follow them, map them or bind props to them.
Usage
Scroll a list in a test.
This type is used by List
// Scroll a list in a test.
import { List, Text } from 'kuito';
import { assert, render, screen, scroll, test } from 'kuito/tests';
const rows = Array.from({ length: 200 }, (_, index) => `Row ${index}`);
const Long = () => <List data={rows} renderItem={({ item }) => <Text height={44}>{item}</Text>} />;
test('rows far down bind once the list scrolls to them', async () => {
await render(<Long />);
assert.equal(screen.queryByText('Row 150'), null);
await scroll(screen.getByText('Row 0'), { y: 150 * 44 });
assert.ok(screen.getByText('Row 150'));
});Type declaration
export interface ScrollMotion {
/** Points along the view's axis from the start of its content, within its scroll range. */
readonly offset: Motion<number>;
/** Points per second toward the content's end; 0 once it has been still for 1/30 s, and for a first move from rest. */
readonly velocity: Motion<number>;
/** Points pulled past an end, negative before the start; 0 within the range. */
readonly overscroll: Motion<number>;
}Members 3
| Name | Type | Required | Description |
|---|---|---|---|
offsetreadonly | Motion<number> | Yes | Points along the view's axis from the start of its content, within its scroll range. |
velocityreadonly | Motion<number> | Yes | Points per second toward the content's end; 0 once it has been still for 1/30 s, and for a first move from rest. |
overscrollreadonly | Motion<number> | Yes | Points pulled past an end, negative before the start; 0 within the range. |
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.