Switch over to WebAssembly, Rust and Yew #35
@ -72,6 +72,7 @@ features = [
|
||||
"Element",
|
||||
"IntersectionObserver",
|
||||
"IntersectionObserverEntry",
|
||||
"ScrollBehavior",
|
||||
"ScrollToOptions",
|
||||
"Window"
|
||||
]
|
||||
|
@ -1,4 +1,6 @@
|
||||
use yew::{function_component, html, Children, Html, Properties};
|
||||
use web_sys::{window, ScrollBehavior, ScrollToOptions};
|
||||
use yew::{function_component, html, use_effect_with_deps, Children, Html, Properties};
|
||||
use yew_router::prelude::use_location;
|
||||
|
||||
mod footer;
|
||||
pub mod goto_top;
|
||||
@ -13,6 +15,20 @@ pub struct LayoutProps {
|
||||
|
||||
#[function_component(Layout)]
|
||||
pub fn layout(props: &LayoutProps) -> Html {
|
||||
let location = use_location();
|
||||
|
||||
use_effect_with_deps(
|
||||
|_| {
|
||||
let mut opts = ScrollToOptions::new();
|
||||
opts.top(0f64);
|
||||
opts.behavior(ScrollBehavior::Instant);
|
||||
window()
|
||||
.expect("window")
|
||||
.scroll_to_with_scroll_to_options(&opts);
|
||||
},
|
||||
location,
|
||||
);
|
||||
|
||||
html! {
|
||||
<div class="flex flex-col">
|
||||
<navigation::Navigation />
|
||||
|
Loading…
Reference in New Issue
Block a user