From 8ec3979ce5bb80c3fb36712cc6f48a1f18482047 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 8 Dec 2014 01:59:24 -0600 Subject: [PATCH] fix(slideBox): disable autoPlay when disconnected --- js/angular/controller/slideBoxController.js | 4 +++- js/utils/utils.js | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/js/angular/controller/slideBoxController.js b/js/angular/controller/slideBoxController.js index 1319fa3781..a6e3b84bd8 100644 --- a/js/angular/controller/slideBoxController.js +++ b/js/angular/controller/slideBoxController.js @@ -98,7 +98,9 @@ function(scope, element, $log, $document, $$q, $timeout, $interval, $$ionicAttac if (angular.isNumber(newInterval) && newInterval > 0) { self.autoPlayTimeout = $interval(function() { - self.select(self.next()); + if (!ionic.Utils.isScopeDisconnected(scope)) { + self.select(self.next()); + } }, newInterval); } } diff --git a/js/utils/utils.js b/js/utils/utils.js index 563c6fd571..23d593c8c6 100644 --- a/js/utils/utils.js +++ b/js/utils/utils.js @@ -217,6 +217,15 @@ } else { parent.$$childHead = parent.$$childTail = scope; } + }, + + isScopeDisconnected: function(scope) { + var climbScope = scope; + while (climbScope) { + if (climbScope.$$disconnected) return true; + climbScope = climbScope.$parent; + } + return false; } };