From cbe7d47cdde648134d77ef0cd34dae83e5866e9e Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Mon, 20 Sep 2021 10:22:37 +0200 Subject: [PATCH] Always scroll to explanation text fixes #29 --- frontend/src/mathjax-explanation.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/mathjax-explanation.ts b/frontend/src/mathjax-explanation.ts index 95b45c3..94f83eb 100644 --- a/frontend/src/mathjax-explanation.ts +++ b/frontend/src/mathjax-explanation.ts @@ -43,7 +43,8 @@ class MathjaxExplanation extends MathjaxAdapter { // scroll to element if needed const hostEl = this.shadowRoot!.host as HTMLElement; const dy = el.offsetTop - hostEl.offsetTop - hostEl.scrollTop; - if (dy > hostEl.offsetHeight || dy < 0) { + // end of text is below the container or the start of the text is above the container: + if (dy + el.offsetHeight > hostEl.offsetHeight || dy < 0) { hostEl.scrollBy(0, -hostEl.scrollTop + el.offsetTop - hostEl.offsetTop); } el.style.opacity = "1.0";