Crates.io | yew-virtual-scroller |
lib.rs | yew-virtual-scroller |
version | 0.1.0 |
source | src |
created_at | 2020-12-19 21:27:02.900591 |
updated_at | 2020-12-19 21:27:02.900591 |
description | A Yew component for virtual scrolling / scroll windowing |
homepage | |
repository | https://github.com/AircastDev/yew-virtual-scroller |
max_upload_size | |
id | 324686 |
size | 10,489 |
A Yew component for virtual scrolling / scroll windowing -- Only renders the visible content into the dom.
struct MyItem { value: usize }
impl From<MyItem> for yew::Html {
fn from(item: MyItem) -> Self {
html! {
// Each item must be the same height.
<div key={item.value} style="height: 32px;">
{format!("Item: {}", item.value)}
</div>
}
}
}
fn view(&self) -> yew::Html {
// Items is wrapped with an Rc to avoid cloning large lists.
let items = Rc::clone(&self.items);
html! {
<div>
<style>{"
/* Scroller should be constrained in some way so it can scroll */
.scroller {
height: 600px;
}
"}</style>
<VirtualScroller<MyItem>
items={items}
row_height={32.0}
class=Classes::from("scroller")
/>
</div>
}
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.