1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::;
/// Structure passed as a parameter to callback on on_resize event: how big the element is as
/// drawn, in CSS pixels.
///
/// It comes once the element is on the page, and again whenever its size changes, for whatever
/// reason: the window, the content, a style or a sibling. The size comes from the box of the
/// element as drawn on the screen (`getBoundingClientRect`), with its padding and border, as the
/// size in a [`PointerEvent`](crate::PointerEvent) or a [`WheelEvent`](crate::WheelEvent): for an
/// element turned by a transform, it's the box around it. The browser tells of a change at most
/// once a frame, before the frame is drawn.
///
/// Nothing comes while rendering on the server, so the size to start with is the app's own guess.
///
/// ```rust
/// use vertigo::{ResizeEvent, Value, bind, dom};
///
/// // A canvas that draws as much as its size holds, rather than the same picture scaled
/// let size = Value::new((640.0, 400.0));
///
/// let on_resize = bind!(size, |event: ResizeEvent| size.set((event.width, event.height)));
///
/// dom! {
/// <canvas style="width: 100%; height: 50vh;" {on_resize} />
/// };
/// ```