Skip to content

Commit

Permalink
Upgrade smooth-scroll to latest version and switch to jsDelivr CDN.
Browse files Browse the repository at this point in the history
The version of `smooth-scroll` we were using was quite old (v7.1.1) compared
to what is now available (v12).  By upgrading to the latest version, and
slightly tweaking the way we instantiate it to support the new construct,
this resolves the issue with anchor tags with periods being incorrectly
escaped.

Fixes #57.
  • Loading branch information
abernix committed Mar 29, 2018
1 parent c742a22 commit 1ef28df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion layout/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<!-- End Google Tag Manager (noscript) -->
<% } %>
<%- body %>
<script src="<%= url_for('script/smooth-scroll.min.js', { relative: true }) %>"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/smooth-scroll@12.1.5/dist/js/smooth-scroll.min.js"></script>
<script src="<%= url_for('script/main.js', { relative: true }) %>"></script>
<% if (config.apis && config.apis.docsearch) { %>
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
Expand Down
9 changes: 5 additions & 4 deletions source/script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@

if (h2sWithH3s.length) {
createSubMenu(activeLink.parentNode, h2sWithH3s)
smoothScroll.init({
var scroll = new SmoothScroll('a[href*="#"]', {
speed: 400,
callback: function () {
scrolling = false
offset: 20,
after: function () {
scrolling = false;
}
})
});
}

function createSubMenu (container, headers) {
Expand Down
2 changes: 0 additions & 2 deletions source/script/smooth-scroll.min.js

This file was deleted.

0 comments on commit 1ef28df

Please sign in to comment.