Hi Roman,
So I had this same problem.  I wasn't driving the class change through the 
state change events, but I believe you are impacted by the same issue. It 
turns out there is an issue with the ui-view and ng-animate that will not 
allow the animation you desire. Check out my post about it here:
 https://groups.google.com/forum/#!topic/angular/iKpRhrPr8ko

And the github issue opened against it: 
https://github.com/angular/angular.js/issues/6974

If I ever free up some time I'll take a swipe at fixing it, but until then 
I'm just living with the single direction animation. 
Gordon

On Sunday, April 13, 2014 12:47:19 PM UTC-5, Roman wrote:
>
> I'm using $stateChangeStart with ui-router as a means of setting which 
> direction a ui-view transition should go.  I have a state history array and 
> if the toState is the last state visited then I slide the view right 
> instead of left so it looks like you are going "back" to the view, nothing 
> too crazy.
>
> The original problem I had was that the ng-class wouldn't set properly on 
> the current view, only the incoming view, so the current view wouldn't 
> slide right off the screen.  I slowed down the transition and in the chrome 
> console saw that in fact the class was not being set to slide-right.
>
> It started to work perfectly when I added $scope.$apply().  When I make a 
> transition using ui-sref I don't see any errors in the console.  But when I 
> used back/forward I get the $digest already in progress error.
>
> What's the difference between how the back/fwd buttons and ui-sref trigger 
> a state change that would cause the error? Appreciate any insight!
>
>
> The controller:
>
> .controller('PublicController', function ($rootScope, $scope, $location, 
> $anchorScroll) {
>
> $scope.$on('$stateChangeStart', function(e, toState, toParams, fromState, 
> fromParams, error) {
>
> var hist = $scope.$parent.model.stateHistory;
>
> if (hist.length && hist[0].name === toState.name) {
>
> $scope.$parent.model.slideDirection = 'right';
> $scope.$apply();
> hist.shift();
>
> }
> else {
>
> $scope.$parent.model.slideDirection = 'left';
> $scope.$apply();
> hist.unshift(fromState);
> }
>
> $location.hash('');
> $anchorScroll();
> });
> })
>
>
> The view:
>
> <div class="main-public-view" ui-view="main.public" 
> ng-class="{ 
> 'slide-left'  : model.slideDirection === 'left',
> 'slide-right' : model.slideDirection === 'right'
> }"></div>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to