Components / PagedDocumentView
PagedDocumentView
A bar with page and zoom over pages built only when they show.
Example
The component itself, running in WebAssembly, beside its code in a playground. Try it.
Code
use ravenrs::prelude::*;
fn paged_document_view() -> impl View {
let sheet = ImageData::from_fn(120, 170, |x, y| {
// Lines of a page, where a real app would hand over a rendered PDF.
let line = y % 12 < 3 && (10..110).contains(&x) && (14..156).contains(&y);
if line { Color::rgb(0.55, 0.55, 0.6) } else { Color::rgb(0.98, 0.98, 0.97) }
});
PagedDocumentView::new(
48,
|_| Size::new(420.0, 595.0),
// Page 3 has not been drawn yet: it shows a placeholder of the right size.
move |page| sheet.clone().filter(|_| page != 2),
)
.height(400.0)
}