{"id":1905,"date":"2023-12-21T05:00:00","date_gmt":"2023-12-21T13:00:00","guid":{"rendered":"https:\/\/www.angulartraining.com\/daily-newsletter\/?p=1905"},"modified":"2023-12-20T16:04:49","modified_gmt":"2023-12-21T00:04:49","slug":"animated-route-transitions-with-angular-17","status":"publish","type":"post","link":"https:\/\/www.angulartraining.com\/daily-newsletter\/animated-route-transitions-with-angular-17\/","title":{"rendered":"Animated Route Transitions with Angular 17"},"content":{"rendered":"\n<p>Yesterday, we covered <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/css-animation-generator\/\" target=\"_blank\" rel=\"noopener\" title=\"\">how to generate CSS animations<\/a> for our Angular applications. Today, let&#8217;s see how to use such animations as route transitions when navigating from one route to the next:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"456\" height=\"229\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/ng-animation.gif\" alt=\"\" class=\"wp-image-1907\"\/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>The first thing we need to do is add the right providers for animations and transitions along with our routing config:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"322\" height=\"216\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-25.png\" alt=\"\" class=\"wp-image-1908\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-25.png 322w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-25-300x201.png 300w\" sizes=\"auto, (max-width: 322px) 100vw, 322px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>Then, we can create two different animations: One to exit the current &#8220;page&#8221; and one to enter the next &#8220;page.&#8221; In my example, I made two animations called <code>entrance<\/code> and <code>exit<\/code> using the <a href=\"https:\/\/webcode.tools\/css-generator\/keyframe-animation#google_vignette\" target=\"_blank\" rel=\"noopener\" title=\"\">CSS animation generator tool<\/a>:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"461\" height=\"690\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-26.png\" alt=\"\" class=\"wp-image-1909\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-26.png 461w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-26-200x300.png 200w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>Angular has two specific selectors for view transitions: <code>::view-transition-old(root)<\/code> for the exit of the old page and <code>::view-transition-new(root)<\/code> for the entrance of the new page. Our next step is to &#8220;plug&#8221; our animations into these selectors:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"231\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-27.png\" alt=\"\" class=\"wp-image-1910\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-27.png 624w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-27-300x111.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>And&#8230; that&#8217;s it! Router animations are now in place. You can see the <a href=\"https:\/\/stackblitz.com\/edit\/at-route-transitions?description=An%20angular-cli%20project%20based%20on%20@angular\/animations,%20@angular\/common,%20@angular\/compiler,%20@angular\/core,%20@angular\/forms,%20@angular\/platform-browser,%20@angular\/platform-browser-dynamic,%20@angular\/router,%20core-js,%20rxjs,%20tslib%20and%20zone.js&amp;file=src%2Fmain.ts,src%2Fcomponent1%2Fcomponent1.component.html,src%2Fcomponent1%2Fcomponent1.component.css,src%2Fcomponent1%2Fcomponent1.component.ts,src%2Fcomponent2%2Fcomponent2.component.ts,src%2Fcomponent2%2Fcomponent2.component.css,src%2Fglobal_styles.css&amp;title=Angular%20Starter\" target=\"_blank\" rel=\"noopener\" title=\"\">code for that example in action on Stackblitz<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday, we covered how to generate CSS animations for our Angular applications. Today, let&#8217;s see how to use such animations as route transitions when navigating from one route to the next: The first thing we need to do is add the right providers for animations and transitions along with our routing config: Then, we can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,42,25],"tags":[],"class_list":["post-1905","post","type-post","status-publish","format-standard","hentry","category-angular","category-css","category-routing"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/comments?post=1905"}],"version-history":[{"count":3,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1905\/revisions"}],"predecessor-version":[{"id":1912,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1905\/revisions\/1912"}],"wp:attachment":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/media?parent=1905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/categories?post=1905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/tags?post=1905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}