作者JYHuang (夏天到了,冷不起来了说)
看板Ajax
标题[讨论] Settimeout的运作?
时间Wed Apr 30 02:25:07 2008
刚刚自己在写个元件的smooth 缩放~
small: function(){
this.now = this.now - 10;
this.el.style.width = this.now+"px";
if (this.now > 0)
setTimeout(this.small(),1000);
}
不过元件却是马上从最大缩到最小..没有平滑的缩放..
setTimeout的时间间隔调大也是一样...
问题是出在那呢?
还是要用setInterval呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.104.202.201
1F:推 Fenikso:setTimeout(this.small, 1000); 04/30 02:27
2F:→ JYHuang:这样被settimeout呼叫时 this又会从object变成window @@ 04/30 02:37