Skip to content

Commit 2335e9d

Browse files
二一7insummer
authored andcommitted
fix:countdown新增isClearInterval属性 (#340)
1 parent d14eb0e commit 2335e9d

File tree

3 files changed

+48
-15
lines changed

3 files changed

+48
-15
lines changed

dist/behaviors/countdown.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = Behavior({
44
time: {
55
type: Date,
66
value: new Date().getTime() + 86400000,
7-
observer:function(newVal,oldVal) {
8-
if(newVal && !oldVal) {
7+
observer: function (newVal, oldVal) {
8+
if (newVal && !oldVal) {
99
this.getLatestTime();
1010
}
1111
}
@@ -36,6 +36,10 @@ module.exports = Behavior({
3636
countdownType: {
3737
type: String,
3838
value: "normal"
39+
},
40+
isClearInterval: {
41+
type: Boolean,
42+
value: true
3943
}
4044
},
4145
data: {
@@ -48,15 +52,22 @@ module.exports = Behavior({
4852
},
4953

5054
detached: function () {
51-
clearInterval(this.data.timer);
55+
if (this.data.isClearInterval) {
56+
clearInterval(this.data.timer);
57+
}
5258
},
5359

5460
pageLifetimes: {
5561
hide() {
56-
clearInterval(this.data.timer);
62+
if (this.data.isClearInterval) {
63+
clearInterval(this.data.timer);
64+
}
65+
5766
},
5867
show() {
59-
this.getLatestTime();
68+
if (this.data.isClearInterval) {
69+
this.getLatestTime();
70+
}
6071
}
6172
},
6273

examples/dist/behaviors/countdown.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = Behavior({
44
time: {
55
type: Date,
66
value: new Date().getTime() + 86400000,
7-
observer:function(newVal,oldVal) {
8-
if(newVal && !oldVal) {
7+
observer: function (newVal, oldVal) {
8+
if (newVal && !oldVal) {
99
this.getLatestTime();
1010
}
1111
}
@@ -36,6 +36,10 @@ module.exports = Behavior({
3636
countdownType: {
3737
type: String,
3838
value: "normal"
39+
},
40+
isClearInterval: {
41+
type: Boolean,
42+
value: true
3943
}
4044
},
4145
data: {
@@ -48,15 +52,22 @@ module.exports = Behavior({
4852
},
4953

5054
detached: function () {
51-
clearInterval(this.data.timer);
55+
if (this.data.isClearInterval) {
56+
clearInterval(this.data.timer);
57+
}
5258
},
5359

5460
pageLifetimes: {
5561
hide() {
56-
clearInterval(this.data.timer);
62+
if (this.data.isClearInterval) {
63+
clearInterval(this.data.timer);
64+
}
65+
5766
},
5867
show() {
59-
this.getLatestTime();
68+
if (this.data.isClearInterval) {
69+
this.getLatestTime();
70+
}
6071
}
6172
},
6273

src/behaviors/countdown.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = Behavior({
44
time: {
55
type: Date,
66
value: new Date().getTime() + 86400000,
7-
observer:function(newVal,oldVal) {
8-
if(newVal && !oldVal) {
7+
observer: function (newVal, oldVal) {
8+
if (newVal && !oldVal) {
99
this.getLatestTime();
1010
}
1111
}
@@ -36,6 +36,10 @@ module.exports = Behavior({
3636
countdownType: {
3737
type: String,
3838
value: "normal"
39+
},
40+
isClearInterval: {
41+
type: Boolean,
42+
value: true
3943
}
4044
},
4145
data: {
@@ -48,15 +52,22 @@ module.exports = Behavior({
4852
},
4953

5054
detached: function () {
51-
clearInterval(this.data.timer);
55+
if (this.data.isClearInterval) {
56+
clearInterval(this.data.timer);
57+
}
5258
},
5359

5460
pageLifetimes: {
5561
hide() {
56-
clearInterval(this.data.timer);
62+
if (this.data.isClearInterval) {
63+
clearInterval(this.data.timer);
64+
}
65+
5766
},
5867
show() {
59-
this.getLatestTime();
68+
if (this.data.isClearInterval) {
69+
this.getLatestTime();
70+
}
6071
}
6172
},
6273

0 commit comments

Comments
 (0)