I have been struggling for some time now as I am not very proficient in javascript object-oriented programming. My goal is to create a callback API to detect when an element is being scrolled. However, I am facing difficulty in invoking the prototype method from another method. Can someone please assist me with this?
//HTML
//<div style="width:500px;height:500px;"id="myElement"></div>
//JS
mousewheelListen=function(){
this.el.addEventListener('wheel',);//How can I call Scroller.prototype.scrolling() ?
}
Scroller=function(el){//Constructor
this.el=el;
mousewheelListen.call(this);
}
Scroller.prototype.scrolling=function(callback){//
callback.call(this);
}
var el=document.getElementById('myElement');
var myScroller=new Scroller(el);
myScroller.scrolling(function(){//Listening for scrolling events
console.log('scrolling');
});