Skip to content

feat: add on_end_reached infinite scroll to scrollable controls - #45

Merged
AdamMusa merged 2 commits into
mainfrom
feat/end-reached
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
mainfrom
feat/end-reached

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Package A / A2 (end-reached). Engine counterpart: AdamMusa/ruflet-engine#30.

Depends on #43 (A1), which depends on #31 (A0). The branch is stacked because these KEYWORDS lines are shared. Review only the top commit, feat: add on_end_reached infinite scroll to scrollable controls.

What

  • ListView, GridView, Column and Row accept on_end_reached and end_reached_threshold.
  • "end_reached" => GenericEvent is added to GestureEventFactory::EVENT_CLASS_MAP.
  • It is not a value event: nothing is written back into the control's props, and no end_refresh is sent.

Usage

feed = list_view(expand: true, end_reached_threshold: 300,
  controls: first_page.map { |p| post_tile(p) },
  on_end_reached: ->(e) do
    # e.data => {"pixels"=>…, "max_scroll_extent"=>…, "viewport_dimension"=>…}
    next_page(after: feed.children.length).each { |p| feed.children << post_tile(p) }
    page.update
  end)

A reverse: true chat list reaches its "end" at the visual top, so the same handler loads older messages.

Wire and events

  • Props: on_end_reached: true, end_reached_threshold (px, default 200 on the client).
  • Event: end_reached with payload pixels, max_scroll_extent, viewport_dimension.
  • Material and Cupertino behave identically; see the engine PR.

Tests: test/end_reached_compatibility_test.rb, 5 runs, 32 assertions

  • Keywords serialize on all four controls, has_handler?(:end_reached) holds, and both are off by default. A misspelled keyword is rejected.
  • The handler gets event.data as a GenericEvent, the control's props are unchanged, and no message is sent.
  • An infinite-scroll handler appends children and page.update patches them.

verify_pr.sh: ruflet_core 148/148 files, 638 runs PASS; engine +746 PASS, analyze clean; wire-key audit: no new findings.

ListView, GridView, Column and Row accept on_end_reached and
end_reached_threshold. The event carries pixels, max_scroll_extent and
viewport_dimension and is mapped to GenericEvent.
@AdamMusa
AdamMusa merged commit fb29afb into main Oct 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant