From 3f2ccb9b9acb30834cb7759d14b57f884ea03981 Mon Sep 17 00:00:00 2001
From: weru <fromweru@gmail.com>
Date: Thu, 06 May 2021 21:57:29 +0000
Subject: [PATCH] add helper
---
assets/js/index.js | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/assets/js/index.js b/assets/js/index.js
index 3f99ba5..41c526a 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -363,6 +363,24 @@
toggleMenu(event);
});
+ (function backToTop(){
+ const toTop = elem("#toTop");
+ window.addEventListener("scroll", function(e) {
+ const lastKnownScrollPosition = window.scrollY;
+ if(lastKnownScrollPosition >= 200) {
+ toTop.style.display = "flex";
+ const viewPort = window.innerWidth;
+ const maxBodyWidth = 1240;
+ // if(viewPort > maxBodyWidth) {
+ // toTop.style.right = `${((viewPort - maxBodyWidth) / 2)}px`;
+ // }
+ pushClass(toTop, active);
+ } else {
+ deleteClass(toTop, active);
+ }
+ })
+ })();
+
}
window.addEventListener('load', loadActions());
--
Gitblit v1.10.0