improved handling of explicit time()-setting: no re-rendering, just update

the time and call _update(). that avoids flashing of the letters.
This commit is contained in:
Manuel Friedli 2014-06-26 14:13:21 +02:00
parent 3e8252fa13
commit f9b6acf8b6
1 changed files with 8 additions and 12 deletions

20
uhr.js
View File

@ -30,12 +30,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
language: 'de_CH',
theme: 'black',
force: false,
controls: true
controls: true,
time: new Date()
},
start: function() {
if (!this._isOn()) {
var uhr = this;
this._timer = window.setInterval(function() {
uhr.options.time = new Date();
uhr._update();
}, 1000);
this._update();
@ -80,21 +82,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
}
},
time: function(time) {
this.options.time = time;
if (time == null) {
this._currentMinute = -1;
this._update();
this.options.time = new Date();
} else {
if (this._timer != null) {
window.clearInterval(this._timer);
}
var renderer = new UhrRenderer(this._language(), this.element.find('.letterarea'));
var uhr = this;
renderer.render(this, function() {
uhr._show(time);
});
this.options.time = time;
}
this._update();
},
// private variables
_id: -1,
@ -106,7 +103,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
},
_update: function() {
if (this._isOn()) {
var time = new Date();
var time = this.options.time;
if (time.getMinutes() == this._currentMinute) {
return;
}
@ -355,7 +352,7 @@ UhrRenderer.prototype.render = function(uhr, beforeshow) {
break;
default:
if (console !== undefined && typeof console.log == 'function') {
console.log("Unknown layout version: " + this.layout.version);
console.error("Unknown layout version: " + this.layout.version);
}
return;
}
@ -399,7 +396,6 @@ function Letter(value, style) {
} else {
this.style += ' ' + style;
}
console.log(this.getStyle());
}
}
Letter.prototype.toString = function letterToString() {