Skip to content

Commit 4182da3

Browse files
author
tian.liang
committedAug 1, 2018
fix: stop without start.
1 parent 28bfe37 commit 4182da3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎src/base.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ class BlankScreen {
3333
this.onError = options.onError;
3434
this.onSuccess = options.onSuccess;
3535

36+
if (options.autoStart) {
37+
this.start();
38+
}
39+
3640
// 离开页面时,检查白屏。
3741
window.addEventListener('beforeunload', () => {
3842
this.stop();
3943
}, false);
4044
window.addEventListener('unload', () => {
4145
this.stop();
4246
}, false);
43-
44-
if (options.autoStart) {
45-
this.start();
46-
}
4747
}
4848

4949
/*
@@ -110,6 +110,8 @@ class BlankScreen {
110110
}
111111

112112
stop() {
113+
// 没开始的实例(如异步启动但未启动),离开页面时不检查白屏。
114+
if (typeof this._state === 'undefined') { return; }
113115
this._state = 'stop';
114116
clearTimeout(this._timer);
115117
this.loop();

0 commit comments

Comments
 (0)