From 0204ca8980b6bb0d223e83130f5dab8da9bd9a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marian=20D=C3=B6rk?= Date: Mon, 11 Dec 2023 20:50:53 +0100 Subject: [PATCH] on escape scroll --- index.html | 8 +++++++- js/data.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index a9c042e..636fa89 100644 --- a/index.html +++ b/index.html @@ -61,7 +61,13 @@ document.querySelector("body").style.fontSize = fs+"px"; } window.onresize = setFontSize; - + // when pressing escape scroll up and remove hash + document.onkeyup = function(e) { + if (e.key === "Escape") { + window.scrollTo({ top: 0, left: 0, behavior: 'smooth' }); + history.pushState("", document.title, window.location.pathname); + } + } setFontSize(); fetch('data.md') .then(data => data.text()) diff --git a/js/data.js b/js/data.js index 3901612..3cbd939 100644 --- a/js/data.js +++ b/js/data.js @@ -86,7 +86,7 @@ function updateItemPosition(item) { item.x = item.left ? window.innerWidth * 0.05 + item.varianz : window.innerWidth * 0.95 + item.varianz item.domObject.style.top = item.y + "px"; - item.domObject.style.transform = 'translate(${item.varianz}px,0)' + item.domObject.style.transform = `translate(${item.varianz}px,0)` } function updateItemBase(item, session,itemIndex) { item.type = item.markdown ? 'content' : 'actor'