Is there a way to correctly pass the current element to a function designated for the window.onscroll
event?
My goal is to activate myFunction()
when a specific condition occurs. This condition needs to be checked during onscroll
init() {
window.onscroll = function() {
if(this.currentItemCount() > this.totalElements){
this.totalElements = this.currentItemCount();
this.myFunction();
}
};
}
Unfortunately, I am encountering an error stating that this.currentItemCount()
is not recognized as a function. I understand that passing this
to window.onscroll
is necessary, but I'm struggling with the correct syntax.