From d39931dc9dcd684a6b37aaea73646195af5e6b82 Mon Sep 17 00:00:00 2001 From: Wim Barelds Date: Mon, 17 Feb 2014 18:51:53 +0100 Subject: [PATCH] Fixed bug where .start() would restart a timer instead. --- inc/TimeCircles.js | 14 +++++++++----- timecircles.jquery.json | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/inc/TimeCircles.js b/inc/TimeCircles.js index d20e185..79412a5 100644 --- a/inc/TimeCircles.js +++ b/inc/TimeCircles.js @@ -189,6 +189,7 @@ paused: false, last_frame: 0, animation_frame: null, + timer: false, total_duration: null, prev_time: null, drawn_units: [], @@ -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 @@ -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 { @@ -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; diff --git a/timecircles.jquery.json b/timecircles.jquery.json index 99d9ba9..6b61aa8 100644 --- a/timecircles.jquery.json +++ b/timecircles.jquery.json @@ -1,6 +1,6 @@ { "name": "timecircles", - "version": "1.3.0", + "version": "1.3.1", "title": "jQuery TimeCircles", "author": { "name" : "Wim Barelds",