fn scroll_to_element(el: &Element) {
    let el: HtmlElement = el.clone().try_into().unwrap();
    let rect = el.get_bounding_client_rect();
    let scroll_top = window().page_y_offset();
    let y = rect.get_top();
    let target = y + scroll_top;

    js! { @(no_return)
        window.scrollTo(0, @{target});
    }
}
/// Scrolls the page to an element. Only scrolls vertically.
Scrolls the page to an element. Only scrolls vertically.
Scrolls the page to an element . Only scrolls vertically .
fn scroll_to_element(el: &Element) {
    let el: HtmlElement = el.clone().try_into().unwrap();
    let rect = el.get_bounding_client_rect();
    let scroll_top = window().page_y_offset();
    let y = rect.get_top();
    let target = y + scroll_top;
    js! { @(no_return)
        window.scrollTo(0, @{target});
    }
}
fn scroll_to_element ( el : & Element ) { let el : HtmlElement = el . clone ( ) . try_into ( ) . unwrap ( ) ; let rect = el . get_bounding_client_rect ( ) ; let scroll_top = window ( ) . page_y_offset ( ) ; let y = rect . get_top ( ) ; let target = y + scroll_top ; js ! { ( no_return ) window scrollTo ( 0 { target } ) } }
Scrolls the page to an element.
Scrolls the page to an element .
el
&Element