I have a Graph class and I want to pass its prototype function to another function. Here is a small snippet code of the class
function Graph(opts) {
this.filled = opts.filled;
this.max = opts.max || 50;
this.min = opts.min || 0;
this.fixed = 60; //px
this.transitionArr = [];
this.timeoutArr = [];
};
Graph.prototype.stopAnimation = function() {
//stop any css3 transition by removing animation properties
this.removeAnimProps();
//stop if there is any timeout
for (var i = 0; i < this.timeoutArr.length; i++) {
clearTimeout(this.timeoutArr[i]);
}
for (var i = 0; i < this.transitionArr.length; i++) {
this.transitionArr[i].stop();
}
};
And what I'm trying to do do is pass stopAnimation function to iterate over all objects to stop all animations in all objects:
function iterateOverAll(userFunc){
for (var i = 0; i < GraphArr.length; i++) {
GraphArr[i].userFunc();
}
}
iterateOverAll(Graph.prototype.stopAnimation);
However, I'm not sure how to do. Any help please?