REFACTOR: removes self pattern from eyeline lib (#7796)
This commit is contained in:
parent
cea3a027f3
commit
e064db35d9
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue