From: ArthurHoaro Date: Sun, 1 Oct 2017 09:49:17 +0000 (+0200) Subject: Fix jumpy textarea with long content in post edit X-Git-Tag: v0.9.2~1^2~3^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=9c46b347b8118a127ca965106f66bb4d4d43f427;hp=a59bbf50d7530d7e82a91896a210b9da49cb1568;p=github%2Fshaarli%2FShaarli.git Fix jumpy textarea with long content in post edit We manually reset the scroll position, to avoid height = 'auto' jump to the top Fixes #971 --- diff --git a/tpl/default/js/shaarli.js b/tpl/default/js/shaarli.js index 1c66ebbd..55656f80 100644 --- a/tpl/default/js/shaarli.js +++ b/tpl/default/js/shaarli.js @@ -275,8 +275,14 @@ window.onload = function () { }; function init () { function resize () { + /* Fix jumpy resizing: https://stackoverflow.com/a/18262927/1484919 */ + var scrollTop = window.pageYOffset || + (document.documentElement || document.body.parentNode || document.body).scrollTop; + description.style.height = 'auto'; description.style.height = description.scrollHeight+10+'px'; + + window.scrollTo(0, scrollTop); } /* 0-timeout to get the already changed text */ function delayedResize () {