UX: Sync input and preview when user is typing.

This commit is contained in:
Guo Xiang Tan 2017-11-29 09:54:57 +08:00
parent 3334a4b539
commit de17a8e856

View File

@ -137,8 +137,6 @@ export default Ember.Component.extend({
});
Ember.run.schedule("afterRender", () => {
$input.scrollTop(0);
$input.on('touchstart mouseenter', () => {
if (!$preview.is(":visible")) return;
$preview.off('scroll');
@ -146,6 +144,14 @@ export default Ember.Component.extend({
$input.on('scroll', () => {
this._syncScroll(this._syncEditorAndPreviewScroll, $input, $preview);
});
$input.on('keypress', () => {
Ember.run.debounce(
this,
this._syncScroll, this._syncEditorAndPreviewScroll, $input, $preview,
200
);
});
});
$preview.on('touchstart mouseenter', () => {