怎么實現多物體鏈式動畫
for (var i = 0; i < aLi.length; i++) {
? ?aLi[i].timer = null;
? ?aLi[i].onmouseover = function () {
? ? ? ?startMove(this, {width:400, height:200});
? ?}
? ?aLi[i].onmouseout = function () {
? ? ? ?startMove(this, {width:200, height:100});
? ?}
}
多物體需要用this傳入,而鏈式的第二層如果還用this就只能實現第一層,如果第二層使用aLi[i]則需要兩次mouseover才能實現鏈式最終效果
2016-07-17
多物體的鏈式運動第二層不能用this,可用定義var othis=this;,然后在一二層都用othis就可以達到效果了。
不過我還沒弄清為什么,我剛剛提問了,可以關注下,應該有忍能幫忙解答。
2016-05-01
我剛實現了,關鍵點是第二層需要傳入參數,不能用this了,js和html文件都要修改。
可以參考下我的代碼
https://github.com/KaiWang0712/jsExercise.git