Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge case where animation async event fires after loading was hidden #1100

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions js/ext/angular/src/service/ionicLoading.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ function($animate, $document, $ionicTemplateLoader, $ionicBackdrop, $timeout, $q
});

ionic.requestAnimationFrame(function() {
$animate.removeClass(self.element, 'ng-hide');
//Fix for ios: if we center the element twice, it always gets
//position right. Otherwise, it doesn't
ionic.DomUtil.centerElementByMargin(self.element[0]);
//One frame after it's visible, position it
ionic.requestAnimationFrame(function() {
if (self.isShown === undefined || self.isShown)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just do if (self.isShown) { here, and move this.isShown = true; above the requestAnimationFrame?

In reality, this.isShown will always be true inside this function, since requestAnimationFrame is called a few milliseconds later than everything else.

But in our unit tests, requestAnimationFrame is called instantly, so we can move isShown up for the sake of our tests.

{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, our if statement style is always to put the brace on the same line.

$animate.removeClass(self.element, 'ng-hide');
//Fix for ios: if we center the element twice, it always gets
//position right. Otherwise, it doesn't
ionic.DomUtil.centerElementByMargin(self.element[0]);
});
//One frame after it's visible, position it
ionic.requestAnimationFrame(function() {
ionic.DomUtil.centerElementByMargin(self.element[0]);
});
}
});

this.isShown = true;
Expand Down