Skip to content

Commit

Permalink
improve use_infinite_scroll (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
jetli authored May 14, 2022
1 parent 16c09d2 commit 11387ce
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/yew-hooks/src/hooks/use_infinite_scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ where
move || {
load_more.set(false);
},
150,
100,
)
};

use_event(node, "scroll", move |e: Event| {
let element: Element = e.target_unchecked_into();
if element.scroll_height() - element.scroll_top() <= element.client_height() {
if element.scroll_height() - element.scroll_top() <= element.client_height() + 100 {
load_more.set(true);
debounce.run();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/yew-app/src/routes/hooks/use_infinite_scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn infinite_scroll() -> Html {
let state = state.clone();
use_infinite_scroll(node.clone(), move || {
let max = state.current().len() + 1;
let mut more = vec![max, max + 1, max + 2, max + 3, max + 4];
let mut more = vec![max, max + 1, max + 2, max + 3, max + 4, max + 5, max + 6];
state.append(&mut more);
});
}
Expand Down

0 comments on commit 11387ce

Please sign in to comment.