]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #980 from ArthurHoaro/hotfix/textarea-resize-jumpy
authorVirtualTam <virtualtam+github@flibidi.net>
Fri, 6 Oct 2017 12:31:16 +0000 (14:31 +0200)
committerGitHub <noreply@github.com>
Fri, 6 Oct 2017 12:31:16 +0000 (14:31 +0200)
Fix jumpy textarea with long content in post edit

tpl/default/js/shaarli.js

index 1c66ebbdd708f033c5ae26e747e3f313137edee7..55656f80ea39032dd62b321cf6e707aa3e786868 100644 (file)
@@ -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 () {