我有一个Graph
类,我想将它的原型函数传递给另一个函数。这是该类的一小段代码
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();
}
};
而我想要做的是传递stopAnimation
函数来迭代所有对象以停止所有对象中的所有动画:
function iterateOverAll(userFunc){
for (var i = 0; i < GraphArr.length; i++) {
GraphArr[i].userFunc();
}
}
iterateOverAll(Graph.prototype.stopAnimation);
但是,我不知道该怎么做。请问有什么帮助吗?