Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
fix(app): suppression of initial view animation was buggy
Browse files Browse the repository at this point in the history
which led to disabled ng-animations until the view changed once more
  • Loading branch information
Ingo Blenke authored and nickjanssen committed Oct 9, 2014
1 parent 5c5f927 commit fd10c22
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,19 @@ angular.module('CouchCommerceApp', [
// Prevent animation on first page load
.run(['$animate', '$rootScope', function ($animate, $rootScope) {
$animate.enabled(false);
// viewContentLoaded fires twice on page load
var i = 0;

var i = 0;
var off = $rootScope.$on('$viewContentLoaded', function () {
if (i > 1) {
$animate.enabled(true);
if (i === 1) {
// ngAnimate queues animations for postDigest processing.
// Doing the same with re-enabling $animate ensures that animations stay disabled during the initial
// load while becoming available right after the view has been rendered.
$rootScope.$$postDigest(function () {
$animate.enabled(true);
});
off();
}
i += 1;
i++;
});
}])
.run(['trackingService', 'configService', function (trackingService, configService) {
Expand Down

0 comments on commit fd10c22

Please sign in to comment.