From 1044f95ad0898b6a8cffe752e24a8fa3e43d20c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Fri, 26 Oct 2018 06:13:52 +0200 Subject: [PATCH] Improve navigation control --- app/scripts/controllers/design.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/app/scripts/controllers/design.js b/app/scripts/controllers/design.js index 74acb407d..fc817437e 100644 --- a/app/scripts/controllers/design.js +++ b/app/scripts/controllers/design.js @@ -14,6 +14,7 @@ angular.module('icestudio') $scope.profile = profile; $scope.information = {}; $scope.topModule = true; + $scope.isNavigating = false; // Intialization @@ -23,17 +24,23 @@ angular.module('icestudio') $scope.breadcrumbsNavitate = function(selectedItem) { var item; - do { - graph.breadcrumbs.pop(); - item = graph.breadcrumbs.slice(-1)[0]; + if (!$scope.isNavigating) { + $scope.isNavigating = true; + do { + graph.breadcrumbs.pop(); + item = graph.breadcrumbs.slice(-1)[0]; + } + while (selectedItem !== item); + loadSelectedGraph(); } - while (selectedItem !== item); - loadSelectedGraph(); }; $scope.breadcrumbsBack = function() { - graph.breadcrumbs.pop(); - loadSelectedGraph(); + if (!$scope.isNavigating) { + $scope.isNavigating = true; + graph.breadcrumbs.pop(); + loadSelectedGraph(); + } }; function loadSelectedGraph() { @@ -42,7 +49,9 @@ angular.module('icestudio') if (n === 1) { var design = project.get('design'); opt.disabled = false; - graph.loadDesign(design, opt); + graph.loadDesign(design, opt, function() { + $scope.isNavigating = false; + }); $scope.topModule = true; } else { @@ -50,6 +59,7 @@ angular.module('icestudio') var dependency = common.allDependencies[type]; graph.loadDesign(dependency.design, opt, function() { graph.fitContent(); + $scope.isNavigating = false; }); $scope.information = dependency.package; }