- 點(diǎn)擊link的click事件
handleScrollTo-> 滾動(dòng)的距離是:scrollY+eleOffsetTop-(targetOffst/offsetTop)
即:
Window.scrollY+ele.getBoundingClientRect().top-ele.ownerDocument.documentElement.clientTop-(targetOffst/offsetTop)
點(diǎn)擊link的時(shí)候 元素太往上了。 想要距離頂部的菜單欄對(duì)齊
scrollY+eleOffsetTop-(targetOffst/offsetTop)
可以修改targetOffst/offsetTop
即:
Ele.距離文檔頂部間距-(targetOffst/offsetTop)
2.滾動(dòng) link的激活事件
handleScroll->getCurrentActiveLink
Links.push( )->條件是:
ele.getBoundingClientRect().top-container.getBoundingClientRect().top<(targetOffst/offsetTop)+bounds
取最后的一個(gè)link
滾動(dòng)的時(shí)候 滾動(dòng)到底部 最后一個(gè)link沒(méi)有激活
ele.getBoundingClientRect().top-container.getBoundingClientRect().top<(targetOffst/offsetTop)+bounds
可以修改targetOffst/offsetTop和bounds
即
Ele.距離視口窗口頂部間距<(targetOffst/offsetTop)+bounds