Skip to content

Commit

Permalink
Closes #81
Browse files Browse the repository at this point in the history
  • Loading branch information
Samreay committed Jun 8, 2014
1 parent fe4df7b commit f609d29
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ function MainController($scope, $timeout) {
$scope.goToMenu = function(menuOption) {
if (menuOption == 'Detailed') {
$scope.goToDetailed();
} else if (menuOption == 'Overview') {
$scope.ensureInView(false);
}
$scope.interfaceManager.menuActive = menuOption;
};
Expand Down Expand Up @@ -123,8 +125,9 @@ function MainController($scope, $timeout) {
}
$scope.$digest();
};
$scope.checkIfInView = function(element, scrollable) {
$scope.checkIfInView = function(element, scrollable, animate) {
var padding = 100;
var time = animate == false ? 0 : 300;
var docViewTop = $(scrollable).offset().top;
var docViewBottom = docViewTop + $(scrollable).height();

Expand All @@ -133,11 +136,11 @@ function MainController($scope, $timeout) {
var s = 0;
if (elemTop < docViewTop) {
s = docViewTop - elemTop + padding;
$(scrollable).animate({scrollTop: '-='+s}, 300);
$(scrollable).animate({scrollTop: '-='+s}, time);

} else if (elemBottom > docViewBottom) {
s = elemBottom - docViewBottom + padding;
$(scrollable).animate({scrollTop: '+='+s}, 300);
$(scrollable).animate({scrollTop: '+='+s}, time);
}

};
Expand All @@ -148,15 +151,18 @@ function MainController($scope, $timeout) {
$scope.interfaceManager.detailedSettings.unlockBounds(); // So that it can zoom out. Need to rework events. Sigh.
$scope.goToDetailed();
}
$scope.ensureInView(true);
};
$scope.ensureInView = function(animate) {
$timeout(function() {
if ($scope.interfaceManager.overviewGraph) {
$scope.checkIfInView('.overviewList .activeSelect', '#central');
$scope.checkIfInView('.overviewList .activeSelect', '#central', animate);
} else {
$scope.checkIfInView('.overviewTable .activeSelect', '#central');
$scope.checkIfInView('.overviewTable .activeSelect', '#central', animate);
}
$scope.checkIfInView('.spectralList .activeSelect', '.spectralList');
$scope.checkIfInView('.spectralList .activeSelect', '.spectralList', animate);
}, 0, false);
};
}
$scope.toggleDisp = function(category) {
if (category == 'raw') {
$scope.interfaceManager.dispRaw = 1 - $scope.interfaceManager.dispRaw;
Expand Down

0 comments on commit f609d29

Please sign in to comment.