FIX: prevents screen-track from leaking object (#7734)

This commit is contained in:
Joffrey JAFFEUX 2019-06-07 17:18:27 +02:00 committed by GitHub
parent 240b61e844
commit 2dce650b72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,7 +26,8 @@ export default class {
// Create an interval timer if we don't have one. // Create an interval timer if we don't have one.
if (!this._interval) { if (!this._interval) {
this._interval = setInterval(() => this.tick(), 1000); this._interval = setInterval(() => this.tick(), 1000);
$(window).on("scroll.screentrack", this.scrolled.bind(this)); this._boundScrolled = Ember.run.bind(this, this.scrolled);
$(window).on("scroll.screentrack", this._boundScrolled);
} }
this._topicId = topicId; this._topicId = topicId;
@ -39,7 +40,10 @@ export default class {
return; return;
} }
$(window).off("scroll.screentrack", this.scrolled); if (this._boundScrolled) {
$(window).off("scroll.screentrack", this._boundScrolled);
}
this.tick(); this.tick();
this.flush(); this.flush();
this.reset(); this.reset();