Skip to content

Commit

Permalink
better fix for initial scroll jumping
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Jul 20, 2016
1 parent f4dfee4 commit 64841e3
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions core/selection.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,18 +31,13 @@ class Selection {
setTimeout(this.update.bind(this, Emitter.sources.USER), 100); setTimeout(this.update.bind(this, Emitter.sources.USER), 100);
}); });
}); });
let scrollTop = this.root.scrollTop; let scrollTop;
this.root.addEventListener('blur', () => { this.root.addEventListener('blur', () => {
scrollTop = this.root.scrollTop; scrollTop = this.root.scrollTop;
}); });
this.root.addEventListener('focus', () => { this.root.addEventListener('focus', () => {
let oldTop = this.root.scrollTop; if (scrollTop == null) return;
this.root.scrollTop = scrollTop; this.root.scrollTop = scrollTop;
setTimeout(() => {
if (this.root.scrollTop === 0 && oldTop !== 0) {
this.root.scrollTop = scrollTop = oldTop;
}
}, 1);
}); });
this.emitter.on(Emitter.events.EDITOR_CHANGE, (type, delta) => { this.emitter.on(Emitter.events.EDITOR_CHANGE, (type, delta) => {
if (type === Emitter.events.TEXT_CHANGE && delta.length() > 0) { if (type === Emitter.events.TEXT_CHANGE && delta.length() > 0) {
Expand Down

0 comments on commit 64841e3

Please sign in to comment.