0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-04 02:01:58 -05:00

Merge pull request #297 from matthojo/Editor-Scrolling

Debounce scrolling on editor
This commit is contained in:
Hannah Wolfe 2013-07-22 08:00:15 -07:00
commit 7031ce1169

View file

@ -221,7 +221,6 @@
this.initMarkdown(); this.initMarkdown();
this.renderPreview(); this.renderPreview();
// TODO: Debounce
this.$('.CodeMirror-scroll').on('scroll', this.syncScroll); this.$('.CodeMirror-scroll').on('scroll', this.syncScroll);
// Shadow on Markdown if scrolled // Shadow on Markdown if scrolled
@ -254,7 +253,7 @@
}, },
syncScroll: function (e) { syncScroll: _.debounce(function (e) {
var $codeViewport = $(e.target), var $codeViewport = $(e.target),
$previewViewport = $('.entry-preview-content'), $previewViewport = $('.entry-preview-content'),
$codeContent = $('.CodeMirror-sizer'), $codeContent = $('.CodeMirror-sizer'),
@ -268,7 +267,7 @@
// apply new scroll // apply new scroll
$previewViewport.scrollTop(previewPostition); $previewViewport.scrollTop(previewPostition);
}, }, 50),
// This updates the editor preview panel. // This updates the editor preview panel.
// Currently gets called on every key press. // Currently gets called on every key press.