#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 添加了标签
Frontend
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
登陆 并参与到对话中。
未选择里程碑
未指派成员
2 名参与者
到期时间

未设置到期时间。

依赖工单

此工单当前没有任何依赖。

正在加载...
取消
保存
这个人很懒,什么都没留下。