bergben / ng2-page-transition

Simple Angular2 component to create a page transition animation on route changes
MIT License
41 stars 7 forks source link

Trouble on child router-outlet #1

Closed genz10 closed 7 years ago

genz10 commented 7 years ago

Hello, I have some problem caused by child router outlet, when I navigated on the child router, the parent router outlet also triggered animation, so there's 2 animation (it should be 1 animation)

Can it be specified for specific router outlet or any other solution ?

bergben commented 7 years ago

Hey @genz10. Unforunately the component is listening to all router events (see https://github.com/bergben/ng2-page-transition/blob/master/src/ng2-page-transition.component.ts#L25) so it triggers on all route changes. The only thing you could do is wrap the <ng2-page-transition> only around the child router outlet but then you won't have animations on parent route changes. The component is pretty straight forward though, you could adjust it yourself by checking the route change event which is of type NavigationStart https://angular.io/docs/ts/latest/api/router/index/NavigationStart-class.html and see if the new url is a child route?

bergben commented 7 years ago

You can trigger the transition only for routes containing specific strings which should resolve this issue: https://github.com/bergben/ng2-page-transition#onlyonroutes