1 个不稳定版本
0.1.0 | 2020 年 12 月 19 日 |
---|
#1443 in WebAssembly
11KB
136 行代码(不含注释)
yew-virtual-scroller
yew-virtual-scroller 是一个用于虚拟滚动/滚动窗口的 Yew 组件 — 只将可见内容渲染到 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>
}
}
许可协议
根据以下任一协议授权:
- Apache License, Version 2.0 (LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT 或 http://opensource.org/licenses/MIT)
由您选择。
贡献
除非您明确说明,否则任何有意提交以包含在本作品中的贡献,如 Apache-2.0 许可证中定义的,均应按照上述方式双授权,不附加任何额外条款或条件。
依赖项
~12MB
~228K SLoC