From 06ef682a24822ded111d57d54f856fe5525befc9 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Sat, 5 Dec 2015 11:55:07 -0600 Subject: [PATCH] fix(view): proper view lifecycle for caching --- js/angular/service/viewSwitcher.js | 9 +++++---- test/html/nav.html | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/js/angular/service/viewSwitcher.js b/js/angular/service/viewSwitcher.js index bea56a2aa54..6b28383e044 100644 --- a/js/angular/service/viewSwitcher.js +++ b/js/angular/service/viewSwitcher.js @@ -257,10 +257,6 @@ function($timeout, $document, $q, $ionicClickBlock, $ionicConfig, $ionicNavBarDe $timeout.cancel(enteringEle.data(DATA_FALLBACK_TIMER)); leavingEle && $timeout.cancel(leavingEle.data(DATA_FALLBACK_TIMER)); - // emit that the views have finished transitioning - // each parent nav-view will update which views are active and cached - switcher.emit('after', enteringData, leavingData); - // resolve that this one transition (there could be many w/ nested views) deferred && deferred.resolve(navViewCtrl); @@ -268,6 +264,10 @@ function($timeout, $document, $q, $ionicClickBlock, $ionicConfig, $ionicNavBarDe // transition promises should be added to the services array of promises if (transitionId === transitionCounter) { $q.all(transitionPromises).then(ionicViewSwitcher.transitionEnd); + + // emit that the views have finished transitioning + // each parent nav-view will update which views are active and cached + switcher.emit('after', enteringData, leavingData); switcher.cleanup(enteringData); } @@ -276,6 +276,7 @@ function($timeout, $document, $q, $ionicClickBlock, $ionicConfig, $ionicNavBarDe instance.triggerTransitionEnd(); }); + // remove any references that could cause memory issues nextTransition = nextDirection = enteringView = leavingView = enteringEle = leavingEle = null; } diff --git a/test/html/nav.html b/test/html/nav.html index 3dcd555413a..88215f7b845 100644 --- a/test/html/nav.html +++ b/test/html/nav.html @@ -26,6 +26,7 @@ +

Random {{random}}

Things @@ -46,6 +47,7 @@