Closed SharryXu closed 3 years ago
Thanks for opening this issue, maintainers will get back to you as soon as possible!
Issue-Label Bot is automatically applying the label Bug
to this issue, with a confidence of 0.56. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
其实没问题,因为判定点是屏幕最上方,而不是屏幕中心,因此直到「注意事项」到达屏幕最上方前,高亮的项目都是倒数第二个导航选项。
Hi @stevenjoezhang ,非常感谢您的快速回复 👍 ,我想的是能否在滚动后,再判断点击的是哪个选项,然后赋予相应的 Class 参数?这样的话,确实会给人的感觉好很多,您觉得呢?不然容易给人造成一种选不上的感觉。。。
谢谢反馈,但问题是即使在点击之后,最后一个选项正确高亮了,用户一旦滚动页面,即使只滚动了1个像素,高亮的项目就会跃变回倒数第二个,这同样是非常不自然的。
因为这个问题是由于最后一个导航项目所对应的内容不足一页高度导致的,所以理论上你向上滚动鼠标,不管多少,都会带入上一节的内容,所以高亮的项目会因此发生改变是合理的,你觉得呢?
我不确定,对于代码逻辑合理的现象,对于用户而言或许是反直觉的。也许可以看看其他网站/主题是怎么处理的?
嗯嗯,有道理,回头我仔细研究下。再次感谢楼主 👍 。有空了我直接提交 PR,到时候你看看合不合理 😄
看到了一篇用 IntersectionObserver 实现的文章: https://www.zhangxinxu.com/wordpress/2020/12/js-intersectionobserver-nav/
NexT 曾经也用过 IntersectionObserver : https://github.com/theme-next/hexo-theme-next/pull/1125 后来又修改了一次,因为这样判断逻辑是单向的,比较简单和直接。 要彻底解决这个问题,可能需要考虑用户的历史操作,例如点击了哪个选项,是向上还是向下滚动,滚动到位之前用户是否进行了其它操作,等等。
这里微调了一下 #322
This thread has been automatically locked since there has not been any recent activity after it was closed. It is possible issue was solved or at least outdated. Feel free to open new for related bugs.
Issue Checklist
Expected behavior
Actual behavior
Steps to reproduce the behavior
Environment Information
Node.js and NPM Information
Package dependencies Information
Hexo Configuration
NexT Configuration
Other Information
我做了些初步搜索,觉得是如下的两个函数的问题。但是,可能比较不太好修。因为最后一个导航选项对应的内容占比不到一页的高度,所以导致最后一个导航选项不能被正确高亮。
文件地址 https://github.com/next-theme/hexo-theme-next/blob/master/source/js/utils.js