[Timeline] Reduce flicker

Reposition scroll bar in Timeline with RAF instead of timeout;
this ensures that scroll bar is positioned after the current
digest (updating the width) but before the results are rendered
(avoiding flicker.) Fixes #997
This commit is contained in:
Victor Woeltjen
2016-06-07 10:02:52 -07:00
parent b0f06a2195
commit a1b2175801
3 changed files with 13 additions and 9 deletions

View File

@@ -28,7 +28,7 @@ define(
* Controls the pan-zoom state of a timeline view.
* @constructor
*/
function TimelineZoomController($scope, $timeout, ZOOM_CONFIGURATION) {
function TimelineZoomController($scope, $window, ZOOM_CONFIGURATION) {
// Prefer to start with the middle index
var zoomLevels = ZOOM_CONFIGURATION.levels || [1000],
zoomIndex = Math.floor(zoomLevels.length / 2),
@@ -54,9 +54,10 @@ define(
}
function setScroll(x) {
$timeout(function () {
$window.requestAnimationFrame(function () {
$scope.scroll.x = x;
}, 0);
$scope.$apply();
});
}
function initializeZoomFromTimespan(timespan) {