Build scrollMap only on scroll.

This commit is contained in:
Guo Xiang Tan 2017-11-23 21:38:25 +08:00
parent fe94e7c453
commit c5745feac6
1 changed files with 10 additions and 10 deletions

View File

@ -140,12 +140,12 @@ export default Ember.Component.extend({
if (!$preview.is(":visible")) return;
$preview.off('scroll');
if (this.get('shouldBuildScrollMap')) {
this.set('scrollMap', this._buildScrollMap($input, $preview));
this.set('shouldBuildScrollMap', false);
}
$input.on('scroll', () => {
if (this.get('shouldBuildScrollMap')) {
this.set('scrollMap', this._buildScrollMap($input, $preview));
this.set('shouldBuildScrollMap', false);
}
Ember.run.throttle(this, this._syncEditorAndPreviewScroll, $input, $preview, this.get('scrollMap'), 20);
});
});
@ -153,12 +153,12 @@ export default Ember.Component.extend({
$preview.on('touchstart mouseenter', () => {
$input.off('scroll');
if (this.get('shouldBuildScrollMap')) {
this.set('scrollMap', this._buildScrollMap($input, $preview));
this.set('shouldBuildScrollMap', false);
}
$preview.on('scroll', () => {
if (this.get('shouldBuildScrollMap')) {
this.set('scrollMap', this._buildScrollMap($input, $preview));
this.set('shouldBuildScrollMap', false);
}
Ember.run.throttle(this, this._syncPreviewAndEditorScroll, $input, $preview, this.get('scrollMap'), 20);
});
});