- Notifications
You must be signed in to change notification settings - Fork3
A Yew component that emits events when the parent component changes width/height.
AircastDev/yew-component-size
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A Yew component that emits events when the parent component changes width/height.Only compatible with Yew using web_sys.
let onsize =self.link.callback(|size:ComponentSize|{// Access to `size.width` and `size.height`});html!{// Parent that you're tracking the size of must be `position: relative` <div style="position: relative;">// ... <ComponentSizeObserver onsize=onsize /> </div>}
This uses a trick borrowed from Svelte where we use an iframe that is positioned absolutelyto fill it's parent element, and then we listen to the resize event of iframe's window.
Note: This incurs a small cost and so should not be used on a large number of elements at the same time.
Licensed under either of
- Apache License, Version 2.0(LICENSE-APACHE orhttp://www.apache.org/licenses/LICENSE-2.0)
- MIT license(LICENSE-MIT orhttp://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in the work by you, as defined in the Apache-2.0 license, shall bedual licensed as above, without any additional terms or conditions.
About
A Yew component that emits events when the parent component changes width/height.
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.