Skip to content

Commit

Permalink
fix(slidebox): properly cleanup window resize listener
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed Apr 13, 2015
1 parent e86b331 commit 51f8f3c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
5 changes: 4 additions & 1 deletion js/angular/directive/slideBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 2 additions & 11 deletions js/views/sliderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

This comment has been minimized.

Copy link
@chaffeqa

chaffeqa Apr 24, 2015

This errors our in iOS simulator:

246   468715   error    Error: Attempted to assign to readonly property.
kill@http://192.168.1.110:8100/cordovaBundle.js:8423:26
http://192.168.1.110:8100/cordovaBundle.js:54186:22
$broadcast@http://192.168.1.110:8100/cordovaBundle.js:23356:35
$destroy@http://192.168.1.110:8100/cordovaBundle.js:22976:26
destroyViewEle@http://192.168.1.110:8100/cordovaBundle.js:46673:29
cleanup@http://192.168.1.110:8100/cordovaBundle.js:46520:29
transitionComplete@http://192.168.1.110:8100/cordovaBundle.js:46461:33
completeOnTransitionEnd@http://192.168.1.110:8100/cordovaBundle.js:46440:33
eventHandler@http://192.168.1.110:8100/cordovaBundle.js:11650:27

// removed event listeners
if (browser.addEventListener) {
Expand Down
13 changes: 11 additions & 2 deletions test/html/slideBox.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,17 @@
<div ng-controller="SlideCtrl">
<ion-side-menus>
<ion-side-menu-content>
<ion-header-bar left-buttons="leftButtons" right-buttons="rightButtons" title=""></ion-header-bar>
<ion-slide-box on-slide-changed="slideChanged(index)" show-pager="{{$root.showPager}}" pager-click="pagerClick(index)" does-continue="true" auto-play="false">
<ion-header-bar>
<div class="button" ng-click="$root.hideSlideBox = !$root.hideSlideBox">
Toggle
</div>
</ion-header-bar>
<ion-slide-box ng-if="!$root.hideSlideBox"
on-slide-changed="slideChanged(index)"
show-pager="{{$root.showPager}}"
pager-click="pagerClick(index)"
does-continue="true"
auto-play="false">
<ion-slide ng-controller="FirstSlideCtrl">
<h3>Thank you for choosing the Awesome App!</h3>
<div id="logo">
Expand Down

0 comments on commit 51f8f3c

Please sign in to comment.