Debounce scrolling on editor

This commit is contained in:
Matthew Harrison-Jones 2013-07-18 12:06:52 +01:00
parent bf1bb25d06
commit 2ed9a17a66

View File

@ -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.