This commit is contained in:
Maccesch 2024-03-05 20:59:31 +00:00
parent fdb0ac856b
commit 6bd92ca05a
2 changed files with 10 additions and 15 deletions

View file

@ -28,7 +28,6 @@ members = [
"use_element_size",
"use_element_visibility",
"use_event_listener",
"use_event_source",
"use_favicon",
"use_floor",
"use_geolocation",

View file

@ -2,7 +2,6 @@ use crate::core::{ElementMaybeSignal, Size};
use cfg_if::cfg_if;
use default_struct_builder::DefaultBuilder;
use leptos::*;
use wasm_bindgen::prelude::wasm_bindgen;
cfg_if! { if #[cfg(not(feature = "ssr"))] {
use crate::{use_resize_observer_with_options, UseResizeObserverOptions};
@ -137,10 +136,18 @@ where
};
set_width.set(format_box_size.iter().fold(0.0, |acc, v| {
acc + v.as_ref().clone().unchecked_into::<BoxSize>().inline_size()
acc + v
.as_ref()
.clone()
.unchecked_into::<web_sys::ResizeObserverSize>()
.inline_size()
}));
set_height.set(format_box_size.iter().fold(0.0, |acc, v| {
acc + v.as_ref().clone().unchecked_into::<BoxSize>().block_size()
acc + v
.as_ref()
.clone()
.unchecked_into::<web_sys::ResizeObserverSize>()
.block_size()
}))
} else {
// fallback
@ -192,14 +199,3 @@ pub struct UseElementSizeReturn {
/// The height of the element.
pub height: Signal<f64>,
}
#[wasm_bindgen]
extern "C" {
type BoxSize;
#[wasm_bindgen(method, getter = blockSize)]
fn block_size(this: &BoxSize) -> f64;
#[wasm_bindgen(method, getter = inlineSize)]
fn inline_size(this: &BoxSize) -> f64;
}