Fixed initial animation issue

This commit is contained in:
Max Lynch
2013-11-18 19:43:36 -06:00
parent 78a16a9af1
commit feb44cc6d0
6 changed files with 57 additions and 19 deletions

View File

@ -31,16 +31,24 @@ angular.module('ionic.ui.navRouter', [])
link: function($scope, $element, $attr) {
$scope.animation = $attr.animation;
$element.addClass('noop-animation');
var isFirst = true;
var initTransition = function() {
//$element.addClass($scope.animation);
};
var reverseTransition = function() {
console.log('REVERSE');
$element.removeClass('noop-animation');
$element.removeClass($scope.animation);
$element.addClass($scope.animation + '-reverse');
};
var forwardTransition = function() {
console.log('FORWARD');
$element.removeClass('noop-animation');
$element.removeClass($scope.animation + '-reverse');
$element.addClass($scope.animation);
};
@ -56,7 +64,7 @@ angular.module('ionic.ui.navRouter', [])
if(isFirst) {
// Don't animate
//return;
return;
}
if(back) {
@ -72,9 +80,7 @@ angular.module('ionic.ui.navRouter', [])
$rootScope.actualLocation = $location.path();
if(isFirst) {
isFirst = false;
$timeout(function() {
//reverseTransition();
}, 200);
initTransition();
}
});

View File

@ -18,6 +18,7 @@
<script id="page1.html" type="text/ng-template">
<pane>
<h1>Page 1</h1>
<span>{{num}}</span>
<a class="button button-pure" nav-back>Back</a>
<a class="button button-assertive" href="#/page2">Next</a>
</pane>
@ -42,6 +43,7 @@
.config(function($routeProvider, $locationProvider) {
$routeProvider.when('/page1', {
templateUrl: 'page1.html',
controller: 'Page1Ctrl'
});
$routeProvider.when('/page2', {
@ -58,6 +60,10 @@
// configure html5 to get links working on jsfiddle
//$locationProvider.html5Mode(true);
})
.controller('Page1Ctrl', function($scope) {
$scope.num = Math.floor(Math.random() * 100);
});