Commit bde16264 authored by 范雪寒's avatar 范雪寒

fix: timeout

parent c9c31dc1
......@@ -26,6 +26,8 @@ cc.Class({
// 生命周期 onLoad
onLoad() {
this._timeoutIds = [];
this._intervalIds = [];
this._super();
this.initNodes();
this.initSceneData();
......@@ -311,15 +313,15 @@ cc.Class({
},
onTouchPanelLeft() {
this.onTurnLast();
setTimeout(() => {
this._timeoutIds.push(setTimeout(() => {
this.autoPlay();
}, 1500);
}, 1500));
},
onTouchPanelRight() {
this.onTurnNext();
setTimeout(() => {
this._timeoutIds.push(setTimeout(() => {
this.autoPlay();
}, 1500);
}, 1500));
},
......@@ -610,4 +612,16 @@ cc.Class({
})
});
},
_timeoutIds: null,
_intervalIds: null,
// 生命周期
onDestroy() {
this._timeoutIds.forEach(id => {
clearTimeout(id);
});
this._intervalIds.forEach(id => {
clearInterval(id);
});
},
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment