From 51f8f3cdf9fbc470caa2822565ee4308a9b00776 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 13 Apr 2015 14:16:24 -0600 Subject: [PATCH] fix(slidebox): properly cleanup window resize listener --- js/angular/directive/slideBox.js | 5 ++++- js/views/sliderView.js | 13 ++----------- test/html/slideBox.html | 13 +++++++++++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/js/angular/directive/slideBox.js b/js/angular/directive/slideBox.js index 4d02e79333..58f72dc6d2 100644 --- a/js/angular/directive/slideBox.js +++ b/js/angular/directive/slideBox.js @@ -129,7 +129,10 @@ function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory, $ionicScroll return $ionicHistory.isActiveScope($scope); } ); - $scope.$on('$destroy', deregisterInstance); + $scope.$on('$destroy', function() { + deregisterInstance(); + slider.kill(); + }); this.slidesCount = function() { return slider.slidesCount(); diff --git a/js/views/sliderView.js b/js/views/sliderView.js index d04d2368b9..fedd82e937 100644 --- a/js/views/sliderView.js +++ b/js/views/sliderView.js @@ -544,17 +544,8 @@ ionic.views.Slider = ionic.views.View.inherit({ element.style.width = ''; element.style.left = ''; - // reset slides - var pos = slides.length; - while(pos--) { - - var slide = slides[pos]; - slide.style.width = ''; - slide.style.left = ''; - - if (browser.transitions) translate(pos, 0, 0); - - } + // reset slides so no refs are held on to + slides && (slides.length = 0); // removed event listeners if (browser.addEventListener) { diff --git a/test/html/slideBox.html b/test/html/slideBox.html index cfaf2f7e29..b5ab2b2b9f 100644 --- a/test/html/slideBox.html +++ b/test/html/slideBox.html @@ -46,8 +46,17 @@
- - + +
+ Toggle +
+
+

Thank you for choosing the Awesome App!