From d48d1e94a91e7ba6190d1f0e4f73697e89bb670b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Mon, 17 Apr 2017 20:37:26 +0200 Subject: [PATCH] Add scrollToTop javascript function --- server/index.php | 16 ++++++++++++++++ server/resources/gpass.css | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/server/index.php b/server/index.php index d94dafd..7ae897d 100644 --- a/server/index.php +++ b/server/index.php @@ -81,6 +81,21 @@ else echo "CLEAR_TIME=$CLEAR_TIME; // Clear master key after 15 minutes\n"; echo "CRYPTO_V1_COMPATIBLE=$CRYPTO_V1_COMPATIBLE;\n"; ?> + document.addEventListener('DOMContentLoaded', function() { + window.onscroll = function(ev) { + document.getElementById("buttonTop").className = (window.pageYOffset > 500) ? "cVisible" : "cInvisible"; + }; +}); + function scrollToTop() + { + if (window.pageYOffset == 0) + return; + target = (window.innerHeight) ? window.innerHeight/5 : 200; + toScroll = (window.pageYOffset > target) ? target : window.pageYOffset; + window.scrollBy(0, -toScroll); + + setTimeout(scrollToTop, 24); + } @@ -88,6 +103,7 @@ else gPass : global Password +
diff --git a/server/resources/gpass.css b/server/resources/gpass.css index 2f2e3b4..02ff3cf 100755 --- a/server/resources/gpass.css +++ b/server/resources/gpass.css @@ -126,4 +126,37 @@ body { position:absolute; width: 100px; z-index: 0; -} \ No newline at end of file +} + +/* From http://www.trucsweb.com/tutoriels/javascript/retour-haut/ */ +a#buttonTop{ + border-radius:3px; + padding:10px; + font-size:3em; + text-align:center; + color:#fff; + background:rgba(0, 0, 0, 0.25); + position:fixed; + right:3%; + opacity:1; + z-index:99999; + transition:all ease-in 0.2s; + backface-visibility: hidden; + -webkit-backface-visibility: hidden; + text-decoration: none; +} +a#buttonTop:before{ content: "\25b2"; } +a#buttonTop:hover{ + background:rgba(0, 0, 0, 1); + transition:all ease-in 0.2s; +} +a#buttonTop.cInvisible{ + bottom:-35px; + opacity:0; + transition:all ease-in 0.5s; +} + +a#buttonTop.cVisible{ + bottom:20px; + opacity:1; +}