ahonn / hexo-theme-even

:rocket: A super concise theme for Hexo
https://ahonn.github.io/hexo-theme-even/
MIT License
1.36k stars 213 forks source link

auto scroll toc && add interval while showing visitTime #267

Closed onns closed 4 years ago

onns commented 4 years ago
  1. 计算页面长度的时候是用的加载之后的值,其中可能有没渲染好的图片或者其它资源后续又撑高了页面,所以应该每次都改
  2. 目录跟随页面滚动而自动滚动,感觉自动折叠的逻辑对多个同级的目录不友好所以选择了这种方式,个人觉得比现在的效果好,可以先用着,pc端的demo页面:Sync Sofa

  1. leancloud对免费账号有并发3次的限制,所以一次无法获取到所有的访问次数,加了个小小的延时,体验优化。
ahonn commented 4 years ago

LGTM

ahonn commented 4 years ago

Thanks for your PR : P

onns commented 4 years ago

Thanks for your PR : P

ᕙ( • ‿ • )ᕗ

onns commented 4 years ago

hello!十分抱歉,之前测试的时候都没有在手机上测试过整个页面完整的划到最后= =!所以发生了问题,感觉新一个pr太奇怪了,可以麻烦你修改一下even.js文件吗😂

https://github.com/ahonn/hexo-theme-even/blob/75f8f67103820f822118b115b908f6e30140fbd0/source/js/src/even.js#L90

要用一个if包裹起来

          if($(".post-toc").css("display") != "none"){
            var maxTocTop = $footer.offset().top - $toc.height() - SPACING;
            var tocCenterThreshold = document.documentElement.scrollTop + window.innerHeight / 2;
            if ($(".toc-link.active").offset() != undefined && $(".toc-link.active").offset().top > tocCenterThreshold) {
              var distanceBetween = $(".post-toc").offset().top - $(".toc-link.active").offset().top;
              $(".post-toc").offset({
                  top: Math.min(maxTocTop, tocCenterThreshold + distanceBetween),
              });
            }
            if (maxTocTop < $(".post-toc").offset().top) {
              $(".post-toc").offset({ top: maxTocTop });
            }
          }
ahonn commented 4 years ago

hello!十分抱歉,之前测试的时候都没有在手机上测试过整个页面完整的划到最后= =!所以发生了问题,感觉新一个pr太奇怪了,可以麻烦你修改一下even.js文件吗😂

https://github.com/ahonn/hexo-theme-even/blob/75f8f67103820f822118b115b908f6e30140fbd0/source/js/src/even.js#L90

要用一个if包裹起来


          if($(".post-toc").css("display") != "none"){

            var maxTocTop = $footer.offset().top - $toc.height() - SPACING;

            var tocCenterThreshold = document.documentElement.scrollTop + window.innerHeight / 2;

            if ($(".toc-link.active").offset() != undefined && $(".toc-link.active").offset().top > tocCenterThreshold) {

              var distanceBetween = $(".post-toc").offset().top - $(".toc-link.active").offset().top;

              $(".post-toc").offset({

                  top: Math.min(maxTocTop, tocCenterThreshold + distanceBetween),

              });

            }

            if (maxTocTop < $(".post-toc").offset().top) {

              $(".post-toc").offset({ top: maxTocTop });

            }

          }

新发个 PR 来修吧