Skip to content

Commit a5ebd35

Browse files
committed
- (Bug Fix) Fixed an issue with the Counter face that would prevent the counter from auto-incrementing if the autoStart property was used.
1 parent e3ae4e9 commit a5ebd35

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

src/flipclock/js/faces/counter.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@
1212

1313
FlipClock.CounterFace = FlipClock.Face.extend({
1414

15-
// autoStart: false,
15+
/**
16+
* Tells the counter clock face if it should auto-increment
17+
*/
18+
19+
shouldAutoIncrement: false,
20+
21+
/**
22+
* Minimum digits the clock face will show
23+
*/
1624

1725
minimumDigits: 2,
1826

@@ -24,9 +32,16 @@
2432
*/
2533

2634
constructor: function(factory, options) {
27-
//factory.timer.interval = 0;
28-
factory.autoStart = options.autoStart ? true : false;
29-
//factory.running = true;
35+
36+
if(typeof options != "object") {
37+
options = {};
38+
}
39+
40+
factory.autoStart = options.autoStart ? true : false;
41+
42+
if(options.autoStart) {
43+
this.shouldAutoIncrement = true;
44+
}
3045

3146
factory.increment = function() {
3247
factory.countdown = false;
@@ -59,7 +74,6 @@
5974
build: function() {
6075
var t = this;
6176
var children = this.factory.$el.find('ul');
62-
var lists = [];
6377
var time = this.factory.getTime().digitize([this.factory.getTime().time]);
6478

6579
if(time.length > children.length) {
@@ -69,31 +83,30 @@
6983
});
7084

7185
list.select(digit);
72-
lists.push(list);
7386
});
7487

7588
}
7689

77-
$.each(lists, function(i, list) {
90+
$.each(this.lists, function(i, list) {
7891
list.play();
7992
});
8093

81-
this.factory.lists = lists;
94+
this.base();
8295
},
8396

8497
/**
8598
* Flip the clock face
8699
*/
87100

88-
flip: function(time, doNotAddPlayClass) {
101+
flip: function(time, doNotAddPlayClass) {
102+
if(this.shouldAutoIncrement) {
103+
this.autoIncrement();
104+
}
105+
89106
if(!time) {
90107
time = this.factory.getTime().digitize([this.factory.getTime().time]);
91108
}
92109

93-
if(this.autoStart) {
94-
this.autoIncrement();
95-
}
96-
97110
this.base(time, doNotAddPlayClass);
98111
},
99112

0 commit comments

Comments
 (0)