Skip to content

Commit

Permalink
Stopped ion-spinner Android animation script from running indefinitely.
Browse files Browse the repository at this point in the history
  • Loading branch information
TechWizEric committed Sep 23, 2015
1 parent 500cf94 commit 9f341a8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
15 changes: 13 additions & 2 deletions js/angular/controller/spinnerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,19 @@
var animations = {

android: function(ele) {
var self = this;

this.stop = false;

var rIndex = 0;
var rotateCircle = 0;
var startTime;
var svgEle = ele.querySelector('g');
var circleEle = ele.querySelector('circle');

function run() {
if (self.stop) return;

var v = easeInOutCubic(Date.now() - startTime, 650);
var scaleX = 1;
var translateX = 0;
Expand Down Expand Up @@ -372,6 +378,7 @@
return function() {
startTime = Date.now();
run();
return self;
};

}
Expand All @@ -392,7 +399,7 @@
'$attrs',
'$ionicConfig',
function($element, $attrs, $ionicConfig) {
var spinnerName;
var spinnerName, anim;

this.init = function() {
spinnerName = $attrs.icon || $ionicConfig.spinner.icon();
Expand All @@ -415,7 +422,11 @@
};

this.start = function() {
animations[spinnerName] && animations[spinnerName]($element[0])();
animations[spinnerName] && (anim = animations[spinnerName]($element[0])());
};

this.stop = function() {
animations[spinnerName] && (anim.stop = true);
};

}]);
Expand Down
5 changes: 5 additions & 0 deletions js/angular/directive/spinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ IonicModule
link: function($scope, $element, $attrs, ctrl) {
var spinnerName = ctrl.init();
$element.addClass('spinner spinner-' + spinnerName);

$element.on('$destroy', function onDestroy()
{
ctrl.stop();
});
}
};
});
2 changes: 2 additions & 0 deletions js/angular/service/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
}
$timeout.cancel(self.durationTimeout);
self.isShown = false;
var loading = self.element.children();
loading.html("");
};

return self;
Expand Down

0 comments on commit 9f341a8

Please sign in to comment.