Skip to content

Commit 1c56b27

Browse files
committed
- (Bug Fix) The loadClockFace method now resets the clock so if the method is called after instantiation, the entire clock face is re-rendered
1 parent 8895118 commit 1c56b27

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

src/flipclock/js/libs/factory.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,18 @@
194194
*/
195195

196196
loadClockFace: function(name, options) {
197-
var face, suffix = 'Face';
197+
var face, suffix = 'Face', hasStopped = false;
198198

199199
name = name.ucfirst()+suffix;
200+
201+
if(this.face.stop) {
202+
this.stop();
203+
hasStopped = true;
204+
}
205+
206+
this.$el.html('');
207+
208+
this.time.minimumDigits = 0;
200209

201210
if(FlipClock[name]) {
202211
face = new FlipClock[name](this, options);
@@ -206,11 +215,16 @@
206215
}
207216

208217
face.build();
209-
210-
return face;
211-
},
218+
219+
this.face = face
220+
221+
if(hasStopped) {
222+
this.start();
223+
}
212224

213-
225+
return this.face;
226+
},
227+
214228
/**
215229
* Load the FlipClock.Lang object
216230
*
@@ -230,7 +244,7 @@
230244
lang = FlipClock.Lang[this.defaultLanguage];
231245
}
232246

233-
return lang;
247+
return this.lang = lang;
234248
},
235249

236250
/**
@@ -269,7 +283,6 @@
269283
var t = this;
270284

271285
if(!t.running && (!t.countdown || t.countdown && t.time.time > 0)) {
272-
273286
t.face.start(t.time);
274287
t.timer.start(function() {
275288
t.flip();
@@ -347,7 +360,7 @@
347360
*
348361
* @param array An array of digits
349362
*/
350-
flip: function(doNotAddPlayClass) {
363+
flip: function(doNotAddPlayClass) {
351364
this.face.flip(false, doNotAddPlayClass);
352365
}
353366

0 commit comments

Comments
 (0)