Skip to content

Commit

Permalink
Remove smooth scroll behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
midudev committed Mar 13, 2024
1 parent 2ed44c8 commit fba564a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
11 changes: 5 additions & 6 deletions src/components/ButtonUp.astro
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@
let timeout: number = 0 // Identificador para clearTimeout
const $button = document.getElementById("scroll-to-top") as HTMLButtonElement

// Constantes para la animación
const displayBlock: string = "block"
const displayNone: string = "none"
const DISPLAY = { BLOCK: "block", NONE: "none" } as const

// Función para mostrar u ocultar el botón
function toggleScrollToTop() {
const scrollTop = document.body.scrollTop || document.documentElement.scrollTop
const display = scrollTop > 20 ? displayBlock : displayNone
const display = scrollTop > 20 ? DISPLAY.BLOCK : DISPLAY.NONE

if ($button) {
const parent = $button.closest("#button-up")
parent?.classList.toggle("opacity-0", display === displayNone)
$button.classList.toggle("cursor-default", display === displayNone)
parent?.classList.toggle("opacity-0", display === DISPLAY.NONE)
$button.classList.toggle("cursor-default", display === DISPLAY.NONE)
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ const { title, description, preloadImgLCP } = Astro.props
position: relative;
}

@media screen and (prefers-reduced-motion: no-preference) {
html {
scroll-behavior: smooth;
}
}

/* Hiding class, making content visible only to screen readers but not visually */
/* "sr" meaning "screen-reader" */
.sr-only:not(:focus):not(:active) {
Expand Down

0 comments on commit fba564a

Please sign in to comment.