Consider this code. Please pay attention to how .style()
derives from element
. The rest is not important for the point I'm hoping to make here.
/// Centers `element` horizontally and vertically inside `canvas`.
/// Returns a `Node` struct containing the calculated position and dimensions
/// of the repositioned `element`.
pub fn center_element(element: &HtmlElement, canvas: &Canvas) -> Node {
let dim = bounding_client_dim(element);
let pos = centered_pos(&dim, &canvas.dim);
{