The Unified and Autonomous Development Platform
Use timer to minimize performance impact of cursor and scroll position remember.
robin shine94e97e957f54
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.jsindex f043a4ebf8..f2a07c543b 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.js+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.js@@ -123,9 +123,17 @@ gitplex.sourceview = {if (tokenPos)gitplex.sourceview.highlightToken(cm, tokenPos);+ // use scroll timer and cursor timer to minimize performance impact of+ // remembering scroll and cursor position+ var scrollTimer;cm.on("scroll", function() {- var scrollInfo = cm.getScrollInfo();- pmease.commons.history.setScrollPos({left: scrollInfo.left, top: scrollInfo.top});+ if (scrollTimer)+ clearTimeout(scrollTimer);+ scrollTimer = setTimeout(function() {+ scrollTimer = undefined;+ var scrollInfo = cm.getScrollInfo();+ pmease.commons.history.setScrollPos({left: scrollInfo.left, top: scrollInfo.top});+ }, 500);});var scrollPos = pmease.commons.history.getScrollPos();if (scrollPos)@@ -138,7 +146,7 @@ gitplex.sourceview = {cursorTimer = setTimeout(function() {cursorTimer = undefined;pmease.commons.history.setCursor(cm.getCursor());- }, 1000);+ }, 500);});var cursor = pmease.commons.history.getCursor();