我想在JavaScript中创建一个具有动画运行的对象,当它完成时调用另一个方法。Javascript对象访问它的属性
function panel_manager() {
this.animating = false;
this.doAnimate = function (nPanel) {
//if we're still moving panels, do nothing
if(this.animating) return;
this.animating = true;
//enlarge new panel
$("#panel" + this.focusedPanel).animate({width:"115px"},1000, this.endAnim);
}
this.endAnim = function() { alert("called"); this.animating = false; }
}
一大堆已经削减了简洁和这个代码的工作时,它是不是一个对象中,并使用全局变量。警报运行,但动画不会改变。
'$( “#面板” + this.focusedPanel).animate(等等,1000,this.endAnim);'< - 'this.endAnim'指的是'$( “#面板” + this.focusedPanel)'。 – 2012-03-02 01:10:42