Merge pull request #3362 from FinnStutzenstein/ScrollImprovement

Scroll improvement
This commit is contained in:
Norman Jäckel 2017-08-18 14:30:43 +02:00 committed by GitHub
commit c4fe50b38d

View File

@ -227,28 +227,9 @@ angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core'])
}); });
}; };
// This function scrolls the projector smoothly. It scrolls is steps calling each
// step with a little timeout.
var STEPS = 5;
$scope.scroll = 0; $scope.scroll = 0;
var setScroll = function (scroll) { var setScroll = function (scroll) {
scroll = -250 * scroll; $scope.scroll = -250 * scroll;
if ($scope.scrollTimeout) {
$timeout.cancel($scope.scrollTimeout);
}
var oldScroll = $scope.scroll;
var diff = scroll - oldScroll;
var count = 0;
if (scroll !== oldScroll) {
var scrollFunction = function () {
$scope.scroll += diff/STEPS;
count++;
if (count < STEPS) {
$scope.scrollTimeout = $timeout(scrollFunction, 1);
}
};
scrollFunction();
}
}; };
$scope.$watch(function () { $scope.$watch(function () {