Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wayjam/hugo-theme-mixedpaper.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayJam So <imsuwj@gmail.com>2020-05-03 15:29:11 +0300
committerWayJam So <imsuwj@gmail.com>2020-05-03 15:29:11 +0300
commit4684fca2c8817b1baf2c2be7ff3993b2080a62a1 (patch)
tree67cc7ea378b02e21b0504ac8e4dcaa7a40b68ac7 /assets/js/main.js
Initial
Diffstat (limited to 'assets/js/main.js')
-rw-r--r--assets/js/main.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/assets/js/main.js b/assets/js/main.js
new file mode 100644
index 0000000..6503c3a
--- /dev/null
+++ b/assets/js/main.js
@@ -0,0 +1,19 @@
+(function() {
+ const backToTopBtn = document.getElementById("back_to_top");
+
+ window.onscroll = function() {
+ scrollFunction(backToTopBtn);
+ };
+})();
+
+function scrollFunction(btn) {
+ const pageOffset =
+ document.documentElement.scrollTop || document.body.scrollTop;
+ if (btn) btn.style.visibility = pageOffset > 450 ? "visible" : "hidden";
+}
+
+// When the user clicks on the button, scroll to the top of the document
+function backToTop() {
+ document.body.scrollTop = 0; // For Safari
+ document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
+}