From b627e0c50e727d8357f67d8e702dc37a534e593d Mon Sep 17 00:00:00 2001 From: Jens Melgaard Date: Mon, 22 Apr 2013 10:27:12 +0200 Subject: [PATCH] added doAnimate to ui-view so when child views are loaded along with parent views, they get animated as a hole and not individually --- .gitignore | 3 +++ sample/contacts.detail.html | 2 +- sample/contacts.html | 2 +- src/viewDirective.js | 17 +++++++++-------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index bb583e677..b713cef55 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ build node_modules .DS_Store *~ + +# webstorm files +.idea diff --git a/sample/contacts.detail.html b/sample/contacts.detail.html index 63f0c2f77..444ed519b 100644 --- a/sample/contacts.detail.html +++ b/sample/contacts.detail.html @@ -6,5 +6,5 @@

{{contact.name}}

{{item.type}} -
+
diff --git a/sample/contacts.html b/sample/contacts.html index 6e98683d6..2df60eae5 100644 --- a/sample/contacts.html +++ b/sample/contacts.html @@ -14,5 +14,5 @@
-
+
diff --git a/src/viewDirective.js b/src/viewDirective.js index 8bb089bb2..3c8033878 100644 --- a/src/viewDirective.js +++ b/src/viewDirective.js @@ -9,9 +9,10 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an terminal: true, link: function(scope, element, attr) { var viewScope, viewLocals, - name = attr[directive.name] || attr.name || '', - onloadExp = attr.onload || '', - animate = $animator && $animator(scope, attr); + name = attr[directive.name] || attr.name || '', + onloadExp = attr.onload || '', + doAnimate = isDefined($animator), + animate = $animator(scope, attr); // Find the details of the parent view directive (if any) and use it // to derive our own qualified view name, then hang our own details @@ -21,16 +22,16 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an var view = { name: name, state: null }; element.data('$uiView', view); - scope.$on('$stateChangeSuccess', updateView); - updateView(); + scope.$on('$stateChangeSuccess', function() { updateView(doAnimate); }); + updateView(false); - function updateView() { + function updateView(doAnimate) { var locals = $state.$current && $state.$current.locals[name]; if (locals === viewLocals) return; // nothing to do // Destroy previous view scope and remove content (if any) if (viewScope) { - if (animate) animate.leave(element.contents(), element); + if (doAnimate) animate.leave(element.contents(), element); else element.html(''); viewScope.$destroy(); @@ -42,7 +43,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an view.state = locals.$$state; var contents; - if (animate) { + if (doAnimate) { contents = angular.element('
').html(locals.$template).contents(); animate.enter(contents, element); } else {