-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adição do botão para voltar para o topo da pagina
- Loading branch information
Showing
5 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::components::button::LinkBtn; | ||
use leptos::*; | ||
use leptos_use::use_window_scroll; | ||
use web_sys::{ScrollBehavior, ScrollToOptions}; | ||
|
||
#[component] | ||
pub fn BackToTopBtn() -> impl IntoView { | ||
let (_, y) = use_window_scroll(); | ||
|
||
let opacity_btn = move || { | ||
if y() > 300.0 { | ||
1 | ||
} else { | ||
0 | ||
} | ||
}; | ||
|
||
let on_click_go_to_top = |_| { | ||
window().scroll_to_with_scroll_to_options( | ||
ScrollToOptions::new() | ||
.behavior(ScrollBehavior::Smooth) | ||
.top(0.0), | ||
); | ||
}; | ||
|
||
view! { | ||
<div style:opacity=opacity_btn class="tw-fixed tw-bottom-4 tw-right-4 tw-transition-opacity tw-duration-700 tw-ease-in-out"> | ||
<LinkBtn href="#" on:click=on_click_go_to_top> | ||
<i class="fa-solid fa-chevron-up"/> | ||
</LinkBtn> | ||
</div> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod back_to_top; | ||
pub mod button; | ||
pub mod card; | ||
pub mod content; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters