Skip to content

Commit

Permalink
Fixed bug where .start() would restart a timer instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
wimbarelds committed Feb 17, 2014
1 parent 0d4a548 commit d39931d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions inc/TimeCircles.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
paused: false,
last_frame: 0,
animation_frame: null,
timer: false,
total_duration: null,
prev_time: null,
drawn_units: [],
Expand Down Expand Up @@ -529,8 +530,10 @@
this.data.attributes.ref_date = parse_date(attr_data_date);
}
// Check if this is an unpause of a timer
else if (typeof this.data.attributes.timer === "number") {
this.data.attributes.ref_date = (new Date()).getTime() + (this.data.attributes.timer * 1000);
else if (typeof this.data.timer === "number") {
if(this.data.paused) {
this.data.attributes.ref_date = (new Date()).getTime() + (this.data.timer * 1000);
}
}
else {
// Try to get data-timer
Expand All @@ -542,6 +545,7 @@
attr_data_timer = parseFloat(attr_data_timer);
}
if(typeof attr_data_timer === "number") {
this.data.timer = attr_data_timer;
this.data.attributes.ref_date = (new Date()).getTime() + (attr_data_timer * 1000);
}
else {
Expand All @@ -557,13 +561,13 @@
};

TC_Instance.prototype.restart = function() {
this.data.attributes.timer = null;
this.data.timer = false;
this.start();
};

TC_Instance.prototype.stop = function() {
if (typeof this.data.attributes.timer === "number") {
this.data.attributes.timer = this.timeLeft(this);
if (typeof this.data.timer === "number") {
this.data.timer = this.timeLeft(this);
}
// Stop running
this.data.paused = true;
Expand Down
2 changes: 1 addition & 1 deletion timecircles.jquery.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "timecircles",
"version": "1.3.0",
"version": "1.3.1",
"title": "jQuery TimeCircles",
"author": {
"name" : "Wim Barelds",
Expand Down

0 comments on commit d39931d

Please sign in to comment.