diff --git a/CHANGELOG b/CHANGELOG index 1f2d1d363..d6ceb96df 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -38,6 +38,7 @@ Core: - Removed our db-session backend and added possibility to use any django session backend. - New csv import layout. - Replaced angular-csv-import through Papa Parse for csv parsing. +- Added smooth projector scroll. Motions: - Added adjustable line numbering mode (outside, inside, none) for each diff --git a/openslides/core/static/js/core/projector.js b/openslides/core/static/js/core/projector.js index 264bd19a6..0130477f6 100644 --- a/openslides/core/static/js/core/projector.js +++ b/openslides/core/static/js/core/projector.js @@ -145,11 +145,12 @@ angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core']) .controller('ProjectorCtrl', [ '$scope', '$location', + '$timeout', 'Projector', 'slides', 'Config', 'ProjectorID', - function($scope, $location, Projector, slides, Config, ProjectorID) { + function($scope, $location, $timeout, Projector, slides, Config, ProjectorID) { var projectorId = ProjectorID(); $scope.broadcast = 0; @@ -165,6 +166,30 @@ 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; + var setScroll = function (scroll) { + scroll = 80 * 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 () { return Projector.lastModified(projectorId); }, function () { @@ -174,14 +199,15 @@ angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core']) setElements($scope.projector); $scope.blank = $scope.projector.blank; } + setScroll($scope.projector.scroll); } else { // Blank projector on error $scope.elements = []; $scope.projector = { - scroll: 0, scale: 0, blank: true }; + setScroll(0); } }); diff --git a/openslides/core/static/templates/projector.html b/openslides/core/static/templates/projector.html index 90e89455b..024914823 100644 --- a/openslides/core/static/templates/projector.html +++ b/openslides/core/static/templates/projector.html @@ -44,7 +44,7 @@