From e69b9bc36b6cad8b5cbc8886ca0e204d712b92b3 Mon Sep 17 00:00:00 2001 From: flifloo Date: Mon, 18 May 2020 13:07:53 +0200 Subject: [PATCH] Adding auto scroll --- public/css/main.css | 2 +- public/js/main.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/public/css/main.css b/public/css/main.css index 361146a..22b6cdb 100644 --- a/public/css/main.css +++ b/public/css/main.css @@ -161,7 +161,7 @@ input:focus{ } .hide{ - /*display: none;*/ + display: none; } h2#cookie_text{ diff --git a/public/js/main.js b/public/js/main.js index 30477ad..228759a 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -21,6 +21,16 @@ main.querySelector("#email").addEventListener("keyup", e => { mailValid(); }); +let observer = new IntersectionObserver(function(entries) { + if(entries[0].isIntersecting === true) + window.scrollTo({top: entries[0].target.getBoundingClientRect().top + window.scrollY, + left: 0, + behavior: 'smooth'}); +}, { rootMargin: "0px", threshold: 0.2 }); + +for (let e of [main, resultMail, passwordTest, resultPassword, passwordManage, security2AF, cookie]) + observer.observe(e); + resultMail.querySelector("a").addEventListener("click", () => { passwordTest.classList.remove("hide"); passwordTest.scrollIntoView({"behavior": "smooth"});