From f3462245d5055fc7da56453117045be7c25291f9 Mon Sep 17 00:00:00 2001 From: Matthew Harrison-Jones Date: Thu, 18 Jul 2013 12:06:52 +0100 Subject: [PATCH] Debounce scrolling on editor --- core/client/views/editor.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/client/views/editor.js b/core/client/views/editor.js index 3e89b03235..827f631d45 100644 --- a/core/client/views/editor.js +++ b/core/client/views/editor.js @@ -167,7 +167,6 @@ this.initMarkdown(); this.renderPreview(); - // TODO: Debounce this.$('.CodeMirror-scroll').on('scroll', this.syncScroll); // Shadow on Markdown if scrolled @@ -200,7 +199,7 @@ }, - syncScroll: function (e) { + syncScroll: _.debounce(function (e) { var $codeViewport = $(e.target), $previewViewport = $('.entry-preview-content'), $codeContent = $('.CodeMirror-sizer'), @@ -214,7 +213,7 @@ // apply new scroll $previewViewport.scrollTop(previewPostition); - }, + }, 50), // This updates the editor preview panel. // Currently gets called on every key press.