Add Missing Fields From Scroll Event (#4022)
* Add onscroll field data * Add bun 1.2.10 generated file changes * Improve error messaging when bun is not installed
This commit is contained in:
1 parent
d00636ca31
commit
c9ca9f32ad
14 files changed
+281
-37
No files matched your search
@@ -25,29 +25,79 @@ impl ScrollData {
|
||||
pub fn downcast<T: 'static>(&self) -> Option<&T> {
|
||||
self.inner.as_any().downcast_ref::<T>()
|
||||
}
|
||||
|
||||
pub fn scroll_top(&self) -> i32 {
|
||||
self.inner.scroll_top()
|
||||
}
|
||||
|
||||
pub fn scroll_left(&self) -> i32 {
|
||||
self.inner.scroll_left()
|
||||
}
|
||||
|
||||
pub fn scroll_width(&self) -> i32 {
|
||||
self.inner.scroll_width()
|
||||
}
|
||||
|
||||
pub fn scroll_height(&self) -> i32 {
|
||||
self.inner.scroll_height()
|
||||
}
|
||||
|
||||
pub fn client_width(&self) -> i32 {
|
||||
self.inner.client_width()
|
||||
}
|
||||
|
||||
pub fn client_height(&self) -> i32 {
|
||||
self.inner.client_height()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for ScrollData {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("ScrollData").finish()
|
||||
f.debug_struct("ScrollData")
|
||||
.field("scroll_top", &self.scroll_top())
|
||||
.field("scroll_left", &self.scroll_left())
|
||||
.field("scroll_width", &self.scroll_width())
|
||||
.field("scroll_height", &self.scroll_height())
|
||||
.field("client_width", &self.client_width())
|
||||
.field("client_height", &self.client_height())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for ScrollData {
|
||||
fn eq(&self, _other: &Self) -> bool {
|
||||
true
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.scroll_top() == other.scroll_top()
|
||||
&& self.scroll_left() == other.scroll_left()
|
||||
&& self.scroll_width() == other.scroll_width()
|
||||
&& self.scroll_height() == other.scroll_height()
|
||||
&& self.client_width() == other.client_width()
|
||||
&& self.client_height() == other.client_height()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
/// A serialized version of ScrollData
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)]
|
||||
pub struct SerializedScrollData {}
|
||||
pub struct SerializedScrollData {
|
||||
pub scroll_top: i32,
|
||||
pub scroll_left: i32,
|
||||
pub scroll_width: i32,
|
||||
pub scroll_height: i32,
|
||||
pub client_width: i32,
|
||||
pub client_height: i32,
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
impl From<&ScrollData> for SerializedScrollData {
|
||||
fn from(_: &ScrollData) -> Self {
|
||||
Self {}
|
||||
fn from(data: &ScrollData) -> Self {
|
||||
Self {
|
||||
scroll_top: data.inner.scroll_top(),
|
||||
scroll_left: data.inner.scroll_left(),
|
||||
scroll_width: data.inner.scroll_width(),
|
||||
scroll_height: data.inner.scroll_height(),
|
||||
client_width: data.inner.client_width(),
|
||||
client_height: data.inner.client_height(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +106,30 @@ impl HasScrollData for SerializedScrollData {
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn scroll_top(&self) -> i32 {
|
||||
self.scroll_top
|
||||
}
|
||||
|
||||
fn scroll_left(&self) -> i32 {
|
||||
self.scroll_left
|
||||
}
|
||||
|
||||
fn scroll_width(&self) -> i32 {
|
||||
self.scroll_width
|
||||
}
|
||||
|
||||
fn scroll_height(&self) -> i32 {
|
||||
self.scroll_height
|
||||
}
|
||||
|
||||
fn client_width(&self) -> i32 {
|
||||
self.client_width
|
||||
}
|
||||
|
||||
fn client_height(&self) -> i32 {
|
||||
self.client_height
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
@@ -76,8 +150,26 @@ impl<'de> serde::Deserialize<'de> for ScrollData {
|
||||
}
|
||||
|
||||
pub trait HasScrollData: std::any::Any {
|
||||
/// return self as Any
|
||||
/// Return self as Any
|
||||
fn as_any(&self) -> &dyn std::any::Any;
|
||||
|
||||
/// Get the vertical scroll position
|
||||
fn scroll_top(&self) -> i32;
|
||||
|
||||
/// Get the horizontal scroll position
|
||||
fn scroll_left(&self) -> i32;
|
||||
|
||||
/// Get the total scrollable width
|
||||
fn scroll_width(&self) -> i32;
|
||||
|
||||
/// Get the total scrollable height
|
||||
fn scroll_height(&self) -> i32;
|
||||
|
||||
/// Get the viewport width
|
||||
fn client_width(&self) -> i32;
|
||||
|
||||
/// Get the viewport height
|
||||
fn client_height(&self) -> i32;
|
||||
}
|
||||
|
||||
impl_event! {
|
||||
|
||||
Reference in new issue
Block a user