diff --git a/app/assets/javascripts/discourse/lib/eyeline.js.es6 b/app/assets/javascripts/discourse/lib/eyeline.js.es6 index e18f0a4554..f49801f099 100644 --- a/app/assets/javascripts/discourse/lib/eyeline.js.es6 +++ b/app/assets/javascripts/discourse/lib/eyeline.js.es6 @@ -12,8 +12,7 @@ Eyeline.prototype.update = function() { windowHeight = $(window).height(), docViewBottom = docViewTop + windowHeight, $elements = $(this.selector), - bottomOffset = $elements.last().offset(), - self = this; + bottomOffset = $elements.last().offset(); let atBottom = false; if (bottomOffset) { @@ -21,7 +20,7 @@ Eyeline.prototype.update = function() { bottomOffset.top <= docViewBottom && bottomOffset.top >= docViewTop; } - return $elements.each(function(i, elem) { + return $elements.each((i, elem) => { const $elem = $(elem), elemTop = $elem.offset().top, elemBottom = elemTop + $elem.height(); @@ -45,17 +44,17 @@ Eyeline.prototype.update = function() { // If you hit the bottom we mark all the elements as seen. Otherwise, just the first one if (!atBottom) { - self.trigger("saw", { detail: $elem }); + this.trigger("saw", { detail: $elem }); if (i === 0) { - self.trigger("sawTop", { detail: $elem }); + this.trigger("sawTop", { detail: $elem }); } return false; } if (i === 0) { - self.trigger("sawTop", { detail: $elem }); + this.trigger("sawTop", { detail: $elem }); } if (i === $elements.length - 1) { - return self.trigger("sawBottom", { detail: $elem }); + return this.trigger("sawBottom", { detail: $elem }); } }); }; @@ -65,10 +64,8 @@ Eyeline.prototype.flushRest = function() { if (Ember.testing) { return; } - const self = this; - $(this.selector).each(function(i, elem) { - return self.trigger("saw", { detail: $(elem) }); - }); + + $(this.selector).each((i, elem) => this.trigger("saw", { detail: $(elem) })); }; RSVP.EventTarget.mixin(Eyeline.prototype);