From 8ef3cb539461ae14e1e7fb9a5c901942f4bbf860 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Mon, 20 Jul 2020 16:03:05 -0400 Subject: [PATCH] Don't auto scroll when already scrolled ahead Fixes #294 --- neuron/src/lib/Neuron/Web/Widget/AutoScroll.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neuron/src/lib/Neuron/Web/Widget/AutoScroll.hs b/neuron/src/lib/Neuron/Web/Widget/AutoScroll.hs index 5d7632253..8b8ffeb7e 100644 --- a/neuron/src/lib/Neuron/Web/Widget/AutoScroll.hs +++ b/neuron/src/lib/Neuron/Web/Widget/AutoScroll.hs @@ -24,5 +24,5 @@ marker elemId offsetPx = do script :: DomBuilder t m => Text -> m () script markerId = do let s = - "document.getElementById(\"" <> markerId <> "\").scrollIntoView({behavior: \"smooth\", block: \"start\"});" + "if (window.scrollY == 0) { document.getElementById(\"" <> markerId <> "\").scrollIntoView({behavior: \"smooth\", block: \"start\"}); }" el "script" $ text s