From 338bf31c228269f5e7b6b7c8e23e7ee6b435108c Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Wed, 27 Feb 2013 16:34:26 -0500 Subject: [PATCH] Remove need to call Timeline.updateFromClock. Register for the `Clock.onTick` event instead, which was introduced with the animation branch. This is a minor tweak to bring Timeline in line with other widgets (event driven rather than manual updates from the user). I plan on looking into refactoring Timeline to use knockout/viewModels soon, but I thought this was a good simple change in the mean time. --- Apps/TimelineDemo/TimelineDemo.js | 1 - Source/Widgets/Dojo/CesiumViewerWidget.js | 1 - Source/Widgets/Timeline/Timeline.js | 4 ++++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Apps/TimelineDemo/TimelineDemo.js b/Apps/TimelineDemo/TimelineDemo.js index b7912b18e8f4..f9e009b21316 100644 --- a/Apps/TimelineDemo/TimelineDemo.js +++ b/Apps/TimelineDemo/TimelineDemo.js @@ -101,7 +101,6 @@ define(['dojo', function tick() { var time = clock.tick(); - timeline.updateFromClock(); updateScrubTime(time); requestAnimationFrame(tick); } diff --git a/Source/Widgets/Dojo/CesiumViewerWidget.js b/Source/Widgets/Dojo/CesiumViewerWidget.js index 73cf6ea8a2cd..50d642e28aed 100644 --- a/Source/Widgets/Dojo/CesiumViewerWidget.js +++ b/Source/Widgets/Dojo/CesiumViewerWidget.js @@ -1059,7 +1059,6 @@ define([ } else { currentTime = this.clock.currentTime; } - this.timeline.updateFromClock(); this.visualizers.update(currentTime); // Update the camera to stay centered on the selected object, if any. diff --git a/Source/Widgets/Timeline/Timeline.js b/Source/Widgets/Timeline/Timeline.js index 1db12aedbb1c..24676734381d 100644 --- a/Source/Widgets/Timeline/Timeline.js +++ b/Source/Widgets/Timeline/Timeline.js @@ -75,6 +75,7 @@ define([ } else { this._topElement = id; } + this._clock = clock; this._scrubJulian = clock.currentTime; this._mainTicSpan = -1; @@ -138,6 +139,9 @@ define([ this.addEventListener = function(type, listener, useCapture) { widget._topElement.addEventListener(type, listener, useCapture); }; + + clock.onTick.addEventListener(this.updateFromClock, this); + this.updateFromClock(); } Timeline.prototype.addHighlightRange = function(color, heightInPx) {