In the following example, the scroll area initially populates and updates as expected, but pressing reset while the scroll is at the top will cause the updates to stop.
let (count, set_count) = create_signal(1);
let reset = move |_| set_count(1);
let data: &_ = (0..1000).collect::<Vec<_>>().leak();
let elements = move || data.iter().copied().take(count()).collect::<Vec<_>>();
let scroll_area = create_node_ref();
let _ = use_infinite_scroll(scroll_area, move |_| {
std::future::ready(set_count(count.get_untracked() + 1))
});
view! {
<button on:click=reset>Reset</button>
<div style="height: 20rem; overflow-y: auto" ref=scroll_area>
<For each=elements key=|id| *id children=move |id| view! { <div>{id}</div> }/>
</div>
}
In the following example, the scroll area initially populates and updates as expected, but pressing reset while the scroll is at the top will cause the updates to stop.