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(),
|
windowHeight = $(window).height(),
|
||||||
docViewBottom = docViewTop + windowHeight,
|
docViewBottom = docViewTop + windowHeight,
|
||||||
$elements = $(this.selector),
|
$elements = $(this.selector),
|
||||||
bottomOffset = $elements.last().offset(),
|
bottomOffset = $elements.last().offset();
|
||||||
self = this;
|
|
||||||
|
|
||||||
let atBottom = false;
|
let atBottom = false;
|
||||||
if (bottomOffset) {
|
if (bottomOffset) {
|
||||||
|
@ -21,7 +20,7 @@ Eyeline.prototype.update = function() {
|
||||||
bottomOffset.top <= docViewBottom && bottomOffset.top >= docViewTop;
|
bottomOffset.top <= docViewBottom && bottomOffset.top >= docViewTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $elements.each(function(i, elem) {
|
return $elements.each((i, elem) => {
|
||||||
const $elem = $(elem),
|
const $elem = $(elem),
|
||||||
elemTop = $elem.offset().top,
|
elemTop = $elem.offset().top,
|
||||||
elemBottom = elemTop + $elem.height();
|
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 you hit the bottom we mark all the elements as seen. Otherwise, just the first one
|
||||||
if (!atBottom) {
|
if (!atBottom) {
|
||||||
self.trigger("saw", { detail: $elem });
|
this.trigger("saw", { detail: $elem });
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
self.trigger("sawTop", { detail: $elem });
|
this.trigger("sawTop", { detail: $elem });
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
self.trigger("sawTop", { detail: $elem });
|
this.trigger("sawTop", { detail: $elem });
|
||||||
}
|
}
|
||||||
if (i === $elements.length - 1) {
|
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) {
|
if (Ember.testing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const self = this;
|
|
||||||
$(this.selector).each(function(i, elem) {
|
$(this.selector).each((i, elem) => this.trigger("saw", { detail: $(elem) }));
|
||||||
return self.trigger("saw", { detail: $(elem) });
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RSVP.EventTarget.mixin(Eyeline.prototype);
|
RSVP.EventTarget.mixin(Eyeline.prototype);
|
||||||
|
|
Loading…
Reference in New Issue