Git Product home page Git Product logo

zepplu.github.io's People

Contributors

zepplu avatar

Watchers

 avatar  avatar

zepplu.github.io's Issues

清理庞大的 main.css

修改目录 /_sass/,可能有用的 repo 内搜索关键词:

  • mfp,jquery 扩展 manific-popup 的
  • social-icons,多半用不上
  • highlight,不知道是啥,待研究
  • 字体 family 列表,目前的太长了,需要在不同平台不同浏览器上测试一下,挑出最有用的

APlayer 导致目录里带中文的 heading 链接无效

奇怪之处在于:只有目录里的链接无效了,正文里 heading 前的链接却有效。用 chrome devtools debug 后发现问题出在 webpack://[name]/./node_modules/smoothscroll/smoothscroll.js(这个是啥?),里面有这样的代码:

    var linkHandler = function linkHandler(ev) {
        if (!ev.defaultPrevented) {
            ev.preventDefault();
            if (location.hash !== this.hash)
                window.history.pushState(null, null, this.hash);
            var node = document.getElementById(this.hash.substring(1));
            if (!node)
                return;
            smoothScroll(node, 500, function (el) {
                location.replace('#' + el.id);
            });
        }
    };
    document.addEventListener('DOMContentLoaded', function () {
        var internal = document.querySelectorAll('a[href^="#"]:not([href="#"])'), a;
        for (var i = internal.length; a = internal[--i];) {
            a.addEventListener('click', linkHandler, false);
        }
    });

this.hash(这个又是啥?)出来的是经过了 url encode 的字符,用它来跳转的话自然会失败。所有 hashtag 链接都被加上了这个 listener,但正文里的链接是在 setup.js 尾部动态生成的,所以免于遭难。

既然咱们没法改这个 smoothscroll.js,那可以自己把 event listener 给去掉。但是 removeEventListener() 需要传入与 addEventListener() 相同的参数,显然办不到。SO 上的老哥给出了一个简单粗暴的解决方法:直接复制一个新的 DOM 结点,把原来的替换掉。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.