WRXinYue / valaxy-theme-sakura

A simple, personalized, and cute anime-style blog theme.
https://sakura.valaxy.site/
MIT License
24 stars 4 forks source link

Bug Report: A problem of article toc in an abnormal window size #3

Closed furtherun closed 5 months ago

furtherun commented 6 months ago

Taking this deployed page as an example,

Now, I cannot scroll the page, because it always scrolls to the bottom automatically!

I try this process in the deployed page and the demo of release v0.5.5, both of them have this problem. And I also try it in valaxy page, but no this problem.

However, in a normal case, nobody reads articles on a very wide and flat page, so it may not be a bug.

WRXinYue commented 6 months ago

Thank you for submitting this issue!

We have successfully reproduced the situation you described: when the browser window is resized to a width of 1341px and a height of 270px, refreshing the page and scrolling to the bottom will cause the page to automatically scroll to the bottom, making it impossible to normally scroll and view the content. When the scroll wheel speed is fast, it might be possible to scroll back to the top successfully.

Although users rarely read articles in such a wide and flat window during actual use, this issue still needs to be resolved to ensure a good user experience in all situations.

We will investigate this issue as soon as possible and fix it in the next version. Thank you again for your feedback!

WRXinYue commented 5 months ago

Specifically, when Outline reaches the bottom of the view, as in this example, it triggers scrollIntoView(). Since this is controlling the element within the view, the last tag will cause the toc component to reset to the top when scrollIntoView() is triggered. Therefore, this operation is repeatedly executed during the scrolling process. In the case of the Yun Theme example, this issue does not occur because the toc component always remains at the bottom of the view. The current solution is to disable this view scrolling trigger. For reference, as seen in the source code of the Nuxt UI documentation website, the toc element does not trigger scrollIntoView() when it is out of view.