Hello,
I have a simple timer that updates every 1/10 of a second using setTimeout
/** * * Calculates the time elapsed in milliseconds and displays * the total elapsed * */ showElapsed: function(){ if (me.isStarted){ var lastStart = me.getCurrentStartStop(); var stopTime = lastStart.stop || new Date(); var elapsed; if ((lastStart.stop == null)&&(me.isWindowFocused)){ // clock is running elapsed = me.timeMeta.elapsed + ( stopTime - lastStart.start.getTime() ); setTimeout(me.showElapsed, me.refreshInterval); } else{ elapsed = me.timeMeta.elapsed; } me.displayTime(elapsed); me.removeWindowEvents(); } },
and the caller
var displayTime = function(ms) { // use moment.js to format time $.lblTime.text = moment.utc(ms).format("HH:mm:ss.S"); // after 1 minute, just refresh every second if (ms > 60000){ stopWatchHelper.displayTime = function(ms){ stopWatchHelper.refreshInterval = 1000; $.lblTime.text = moment.utc(ms).format("HH:mm:ss"); }; } };
On each call, it will update a label text with the time transpired.
The problem is, compared to the execution in Android, there is a horrible amount of flicker.
I was wandering if there were any tips on how to reduce this flicker
Thanks,
David