Skip to content

Commit 11387ce

Browse files
authored
improve use_infinite_scroll (#15)
1 parent 16c09d2 commit 11387ce

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

crates/yew-hooks/src/hooks/use_infinite_scroll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ where
6666
move || {
6767
load_more.set(false);
6868
},
69-
150,
69+
100,
7070
)
7171
};
7272

7373
use_event(node, "scroll", move |e: Event| {
7474
let element: Element = e.target_unchecked_into();
75-
if element.scroll_height() - element.scroll_top() <= element.client_height() {
75+
if element.scroll_height() - element.scroll_top() <= element.client_height() + 100 {
7676
load_more.set(true);
7777
debounce.run();
7878
}

examples/yew-app/src/routes/hooks/use_infinite_scroll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn infinite_scroll() -> Html {
1111
let state = state.clone();
1212
use_infinite_scroll(node.clone(), move || {
1313
let max = state.current().len() + 1;
14-
let mut more = vec![max, max + 1, max + 2, max + 3, max + 4];
14+
let mut more = vec![max, max + 1, max + 2, max + 3, max + 4, max + 5, max + 6];
1515
state.append(&mut more);
1616
});
1717
}

0 commit comments

Comments
 (0)