You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Add a delay option to routerLink #17485
[ ] Regression (behavior that used to work and stopped working in a new release)
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Expected behavior
When after clicked routerLink, I want to delay the transition. Like....
What is the motivation / use case for changing the behavior?
I have a sidebar menu in my Angular App.
iOS Safari has swipe back feature.
When using it, it shows latest snapshot on previous screen.
This behavior is really annoying because the menu looks like it's flickering.
I want to delay the transition and close the menu first.
NOTE
Consider using animation frames rather than timeout. That makes sure your animation will finish before the transition whereby timeout doesn't. Also removes the need of keeping that value in sync with your css.
@dblVs
I'm sorry I didn't make it clear enough.
I need to use with anchor tag. Like <a routerLink="/awesome/{{awesome.id}}">My awesome page</a> .
I can't use router.navigate in my own ts files.
The code I wrote in my expected behavior is about routerLink directive in angular/core.
It doesn't matter where you enter the state from. As long as you have done the resolve it should work. And also RouterLink is in @angular/router. (I had similar issue and that's how I fixed it. Check documentation for Resolve on angular.io)
@Pittan It sounds like using a Resolver like @dblVs has suggested would be a good solution. If you were to add the timeout at the RouterLink side, what happens when the user changes router state through the URL? You won't have the same delay and things will look wrong.
If you want to wait, using the Resolver will work in either case.
@Pittan I had the same problem with a menu close transition flickering on navigation. It made the page transitions look very laggy
I extended the routerLink href directive to add in a delay with Observable.timer() - with an additional input [navigationDelay]="150" which you put on the <a> element. I uploaded it on npm as an Angular module that includes the extended routerLink and routerLinkActive directives - you can see how it works there
Activity
dblVs commentedon Jun 14, 2017
Isn't that just resolving the state whenever that animation finishes?
here is a link to the docs that tell you how to do it. In your case that would be
NOTE
Consider using animation frames rather than timeout. That makes sure your animation will finish before the transition whereby timeout doesn't. Also removes the need of keeping that value in sync with your css.
Pittan commentedon Jun 14, 2017
@dblVs
I'm sorry I didn't make it clear enough.
I need to use with anchor tag. Like
<a routerLink="/awesome/{{awesome.id}}">My awesome page</a>.I can't use router.navigate in my own ts files.
The code I wrote in my expected behavior is about routerLink directive in angular/core.
dblVs commentedon Jun 14, 2017
It doesn't matter where you enter the state from. As long as you have done the resolve it should work. And also RouterLink is in @angular/router. (I had similar issue and that's how I fixed it. Check documentation for Resolve on angular.io)
tytskyi commentedon Jun 14, 2017
routerLinkon<a>tag builds correct full URL for open-in-new-tabjasonaden commentedon Jun 27, 2017
@Pittan It sounds like using a
Resolverlike @dblVs has suggested would be a good solution. If you were to add the timeout at theRouterLinkside, what happens when the user changes router state through the URL? You won't have the same delay and things will look wrong.If you want to wait, using the
Resolverwill work in either case.briancodes commentedon Mar 8, 2018
@Pittan I had the same problem with a menu close transition flickering on navigation. It made the page transitions look very laggy
I extended the
routerLinkhref directive to add in a delay with Observable.timer() - with an additional input[navigationDelay]="150"which you put on the<a>element. I uploaded it on npm as an Angular module that includes the extended routerLink and routerLinkActive directives - you can see how it works therePittan commentedon Mar 10, 2018
@briancodes Thanks Brian! This npm module looks great! I'll try the module with my Angular application later.
tkstang commentedon Jun 25, 2018
I resolved a similar issue by creating a DelayResolve which I applied to my routes.
Then it the routes just apply the resolve:
path: 'yourpath', component: YourComponent, resolve: [DelayResolve]dblVs commentedon Jun 26, 2018
@tkstang you could have also used
or even better with rxjs 6
angular-automatic-lock-bot commentedon Sep 13, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.