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

오픈
anam3 년 전을 오픈 · 1개의 코멘트
anam 코멘트됨, 3 년 전

<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 added the
Frontend
label 3 년 전
maeda 코멘트됨, 3 년 전
소유자

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
로그인하여 이 대화에 참여
마일스톤 없음
No Assignees
참여자 2명
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
취소
저장
아직 콘텐츠가 없습니다.