#217 Create smooth scroll behaviour and add padding-top to jumplinks on a page.

Ouvert
créé il y a 3 ans par anam · 1 commentaires
anam a commenté il y a 3 ans

<staging:8080>/

The scroll behaviour for jumplinks scroll on top of the element which due to the sticky menubar being on top blocks the element from being seen.

I would like…

`staging:8080/listpage/

Apply padding-top to the element to allow for the title to be seen and also apply smooth scrolling behaviour for a nicer transition.

`<staging:8080>/` The scroll behaviour for jumplinks scroll on top of the element which due to the sticky menubar being on top blocks the element from being seen. I would like... `<staging:8080>/listpage/ Apply padding-top to the element to allow for the title to be seen and also apply smooth scrolling behaviour for a nicer transition.
anam a ajouté l'étiquette
Frontend
il y a 3 ans
maeda a commenté il y a 3 ans
Propriétaire

so this is two fold solution:

https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo

is how you tell the browser to smooth scroll to.

You will need to get the Y position on the page with something like document.querySelector('#a').offsetY

…and you will need to modify the menu to fire a click function instead of being a link…

a(@click="onScrollyClick") click me
onScrollyClick = e => {
    const OFFSET = 50
    const y = e.target.offsetY - OFFSET
    window.scrollTo({
        top: y,
        left: 0,
        behavior: 'smooth'
    })
}

something like that anyway

so this is two fold solution: https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo is how you tell the browser to smooth scroll to. You will need to get the Y position on the page with something like `document.querySelector('#a').offsetY` ...and you will need to modify the menu to fire a click function instead of being a link... ```pug a(@click="onScrollyClick") click me ``` ```javascript onScrollyClick = e => { const OFFSET = 50 const y = e.target.offsetY - OFFSET window.scrollTo({ top: y, left: 0, behavior: 'smooth' }) } ``` something like that anyway
Connectez-vous pour rejoindre cette conversation.
Aucun jalon
Pas d'assignataires
2 participants
Échéance

Aucune échéance n'a été définie.

Dépendances

Ce ticket n'a actuellement pas de dépendance.

Chargement…
Annuler
Enregistrer
Il n'existe pas encore de contenu.