1

My question could be a little strength since I haven't found any other case like that.

I want to perform views animations, but not always. So far, I had the animation in the .css format:

.view.ng-enter{
    animation: view_enter @anim-view-dur;
}

.view.ng-leave{
    animation: view_leave @anim-view-dur;
}

So when I go from one page to another, it is performed.

The exactly case when I don't want the animation view to be applied is in a page where I have an ScrollSpy Bootstrap sidebar working. Since it's within a view, I had to do the anchor links with a function:

$scope.scrollTo= function (id){ 
        $location.hash(id);
        $anchorScroll();
    };

And when this function is called, it's trigger the view animation. Is there any way to prevent from trigger the view animation in this case?

Thank you very much.

New Dev
  • 48,427
  • 12
  • 87
  • 129
Alex JM
  • 1,084
  • 2
  • 11
  • 32
  • 1
    Would it be acceptable to prevent the `scrollTo` function from triggering the view reload, or is that something that is required? – tasseKATT Oct 29 '14 at 09:34
  • @tasseKATT I've tried, using `$scope.$on('$locationChangeStart', function(ev) { ev.preventDefault(); });` , but then it never change the route, like the links become freeze. Is there any other way to prevent the view reload? Thanks – Alex JM Oct 29 '14 at 10:25
  • Hard to say if it fits your use case, but try setting `reloadOnSearch` to `false` for the route. For example: `templateUrl: 'template.html', controller: 'SomeController', reloadOnSearch: false` – tasseKATT Oct 29 '14 at 10:34
  • If you need `reloadOnSearch` to be `true` and want to prevent the view animation that should be solvable too, just let me know. – tasseKATT Oct 29 '14 at 10:35
  • Hi @tasseKATT, that made it work!!!!! I'm working in my first AngularJS project and I realize that is very powerful, tough to do some simple things sometimes you have to search a lot for it. Many thanks! – Alex JM Nov 02 '14 at 10:09

1 Answers1

0

This was working for me:

// Routes config
app.config(function($routeProvider) {
    $routeProvider
    .when("/", {
        templateUrl : "main.htm"
        controller : "MyController"
        reloadOnSearch : true         
    })
});

You could also use this in router-ui