use crate::{JsJson, dev::JsJsonListDecoder};
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ScrollEvent {
pub scroll_top: f64,
pub scroll_left: f64,
pub scroll_width: f64,
pub scroll_height: f64,
pub client_width: f64,
pub client_height: f64,
}
impl ScrollEvent {
pub(crate) fn from_driver(data: JsJson) -> Result<Self, String> {
data.map_list(|mut params: JsJsonListDecoder| {
let scroll_top = params.get_f64("scrollTop")?;
let scroll_left = params.get_f64("scrollLeft")?;
let scroll_width = params.get_f64("scrollWidth")?;
let scroll_height = params.get_f64("scrollHeight")?;
let client_width = params.get_f64("clientWidth")?;
let client_height = params.get_f64("clientHeight")?;
params.expect_no_more()?;
Ok(Self {
scroll_top,
scroll_left,
scroll_width,
scroll_height,
client_width,
client_height,
})
})
}
}