diff --git a/docs/mini/flavor.scss b/docs/mini/flavor.scss index b3e3f11c0..59775783e 100644 --- a/docs/mini/flavor.scss +++ b/docs/mini/flavor.scss @@ -437,3 +437,20 @@ code[class*="language-"]::selection, code[class*="language-"] ::selection { .token.entity { cursor: help; } + +button.scroll-to-top { + border-radius: 100%; + font-size: 1.5rem; + line-height: 1; + box-sizing: border-box; + width: 2.75rem; + height: 2.75rem; + position: fixed; + bottom: 1rem; + right: 2rem; + background: var(#{$back-color-var}); + box-shadow: 0 .25rem .25rem 0 rgba(0,0,0,0.125),0 .125rem .125rem -.125rem rgba(0,0,0,0.25); + &:hover, &:focus { + background: var(#{$secondary-back-color-var}); + } +} diff --git a/scripts/web.js b/scripts/web.js index 6b86c7683..36864f989 100644 --- a/scripts/web.js +++ b/scripts/web.js @@ -169,7 +169,7 @@ try { .replace(/<\/h3>/g, `${taggedSnippet[1].includes('advanced')?'advanced':''}`) .replace(/
([^\0]*?)<\/code><\/pre>/gm, (match, p1) => `${Prism.highlight(unescapeHTML(p1), Prism.languages.javascript)}`)
.replace(/<\/pre>\s+
Copy to clipboard' +
+ '' +
'';
} else {
output += md
@@ -185,7 +185,7 @@ try {
.replace(/<\/h3>/g, '')
.replace(/([^\0]*?)<\/code><\/pre>/gm, (match, p1) => `${Prism.highlight(unescapeHTML(p1), Prism.languages.javascript)}`)
.replace(/<\/pre>\s+
Copy to clipboard' +
+ '' +
'
';
}
}
diff --git a/static-parts/index-end.html b/static-parts/index-end.html
index d7aef2012..a977f3cb7 100644
--- a/static-parts/index-end.html
+++ b/static-parts/index-end.html
@@ -1,6 +1,6 @@
+
diff --git a/static-parts/index-start.html b/static-parts/index-start.html
index 00bbe441b..e5c0702d1 100644
--- a/static-parts/index-start.html
+++ b/static-parts/index-start.html
@@ -27,6 +27,13 @@
x.style.display = matchingTags.includes(x.innerText.toLowerCase()) ? '' : 'none';
})
}
+ function scrollToTop(){
+ const c = document.querySelector('main').scrollTop;
+ if (c > 0) {
+ window.requestAnimationFrame(scrollToTop);
+ document.querySelector('main').scrollTo(0, c - c / 4);
+ }
+ };
function loader() {
registerClickListener();
}
@@ -54,6 +61,9 @@
},300);
},1700);
}
+ else if (event.target.classList.contains('scroll-to-top')){
+ scrollToTop();
+ }
}, false);
}