Beautiful Router Animations with Angular

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • Create beautiful 🎨 page transitions with the Angular Router by building four different animation sequences from scratch fireship.io/le...
    - Deal Crunch App play.google.co...
    - Angular Router angular.io/gui...
    - Angular Animations angular.io/gui...

Комментарии • 122

  • @damianboryga1229
    @damianboryga1229 4 года назад +23

    I love that i don't have to spent 30mins on watching tutorial about how to install angular cli and all the basics when i just need what i'm searching for. Thank you

  • @zoecarlibur
    @zoecarlibur 5 лет назад +49

    When you think you're an advanced Angular user, And then Jeff makes a video :-\

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 4 года назад +4

      Back to feeling stupid again.. the life of a web developer

    • @minigeek
      @minigeek 3 года назад

      seriously dude

  • @ikezedev
    @ikezedev 5 лет назад +14

    I'll need to re-watch this..... Thanks again Jeff

  • @CharlesX711967
    @CharlesX711967 5 лет назад +34

    Going to add this to my project at work, I'll mail you a percentage of my paycheck.

    • @Fireship
      @Fireship  5 лет назад +8

      Lol, I'll be looking in the mail for that :)

    • @realsandeep
      @realsandeep 4 года назад +5

      @@Fireship Did you get the mail? Tell me what happend in 100 seconds

  • @sauravbhatt5426
    @sauravbhatt5426 Год назад

    thanku so much sir this tutorial help me so much thanku and love from INDIA

  • @-0-__-0-
    @-0-__-0- 2 года назад +1

    Im a beginner in react and Ive always wondered how they're able to transition to a different route very smoothly. Thanks god I found this.

  • @TreyDubya
    @TreyDubya 2 года назад +1

    I've watched so many of your videos in the last 6 months as I've learned FE dev. And this helped me put the final touches on my portfolio site. Thank you so much.

    • @TreyDubya
      @TreyDubya 2 года назад +1

      ​@@matiaslopez9915 I used components and routerLink and got it to work. Idk. I had to adjust the data: object from "left" and "right" to be numbered instead. Look at (and copy from) his repo, that really helped me.

  • @Tonycodes22
    @Tonycodes22 5 лет назад +13

    I get this error but the animations still work.
    ```
    core.js:15713 ERROR Error: Unable to process animations due to the following failed trigger transitions
    @routeAnimations has failed due to:
    - `query(":enter, :leave")` returned zero elements. (Use `query(":enter, :leave", { optional: true })` if you wish to allow this.)
    - `query(":enter")` returned zero elements. (Use `query(":enter", { optional: true })` if you wish to allow this.)
    - `query(":leave")` returned zero elements. (Use `query(":leave", { optional: true })` if you wish to allow this.)
    ```

    • @akshaykarajgikar3849
      @akshaykarajgikar3849 4 года назад +1

      Any luck getting it to work?

    • @alexandergerlach4579
      @alexandergerlach4579 4 года назад +1

      just add ', { optional: true }' (without the quotes) as the last argument of every query, right after ']'.

  • @reyco1
    @reyco1 5 лет назад +17

    I needed this tutorial so bad, man! Came right in the nick of time too :)

    • @Fireship
      @Fireship  5 лет назад +2

      Always great to hear that! Thanks Rey :)

  • @tl8990
    @tl8990 2 года назад

    Thanks for saving my class project by the due day. You are such a brilliant guy.

  • @MercyFromOverwatch2
    @MercyFromOverwatch2 2 года назад

    Jeff is my favourite tech youtuber

  • @robertomanganelly8725
    @robertomanganelly8725 2 года назад

    Simply wonderful. Thanks

  • @tobi-osimosu
    @tobi-osimosu 2 года назад

    Thanks for this video!

  • @ericnjanga3245
    @ericnjanga3245 Год назад

    Very helpful, thank you.

  • @LarsRyeJeppesen
    @LarsRyeJeppesen 4 года назад +2

    ERROR in app/main/containers/app/app.component.ts(32,5): Error during template compile of 'AppComponent'
    Reference to a non-exported function in 'slider'
    'slider' contains the error at app/main/containers/app/route-animations.ts(20,10).

  • @shyagam
    @shyagam 5 лет назад +2

    This doesn't seem to compile when building with *ng build --prod* . The AOT compiler doesn't like the *[direction]* key specification. A workaround is to create a function that returns the direction object:
    *export function* dir(direction: 'left' | 'right', value: *number* | *string* )
    {
    *return* direction === 'left' ? { left: value } : { right: value };
    }
    Then call it like so: *style(dir(direction, 0))* .
    Now it's possible to keep using the same animation function without duplicating it for each direction.
    ( ! ) Notice the *export* keyword as the AOT compiler requires it.

    • @ShaifulBorhan
      @ShaifulBorhan 5 лет назад +1

      do you mind doing a pastebin of this? thanks

    • @ApexHighlightReels
      @ApexHighlightReels 5 лет назад

      how do i call it with style(dir(direction, 0)) ? can you please share a blitz stack or something?

  • @ANUJGROVER01
    @ANUJGROVER01 5 лет назад +1

    Thank you for all such creative tutorials 🧡

    • @Fireship
      @Fireship  5 лет назад +1

      Thank you for watching :)

  • @okopyl
    @okopyl 2 года назад +1

    Thanks a lot for a great video. But the problem with this approach is that when you open a route for the first time, it slides from left or right, but what if I want it to slide only when I switch manually and not when I open them from the first time from URL?
    Basically, I need to cancel the animation if a user comes from the same route or just opened the route for the first time.

  • @Juanmv05
    @Juanmv05 5 лет назад +4

    When I use AOT in "ng build --aot=true", it shows an error: "Functions expressions are not supported in decorators in x references x. Consider changing the function expression into an exported function".
    But, when I change it to "export function", it shows the same error. Some ideas?

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 4 года назад

      Same here, did you ever resolve it?

    • @muhammadfirghi5009
      @muhammadfirghi5009 4 года назад

      Have you resolved this? I tried placing it all under one function, and tried to inject ForRoot and it still did not work

  • @8manjusha
    @8manjusha 5 лет назад +1

    i implemented similar but routing animation works only on first route , on routing to same component again, the routing animation is not working

  • @narendrasinghrathore1012
    @narendrasinghrathore1012 5 лет назад +1

    Great video on animations.
    Waiting something on dynamic components, ng-content, ng-container, content management in angular,( for.eg angular.io ) some advance angular concepts.

  • @shaunb
    @shaunb 5 лет назад +8

    I'm getting the following error that's preventing the animations from triggering: "query(":enter, :leave")` returned zero elements."

    • @Fireship
      @Fireship  5 лет назад +1

      Add '{ optional: true }' to the query. I did not get that locally on the first animation, but that should fix it.

    • @shaunb
      @shaunb 5 лет назад +1

      Thanks for the reply! It got rid of the error message, but the animations still do not fire.

    • @linkinbrr
      @linkinbrr 5 лет назад

      @@shaunb Did you add the #outlet="outlet" at the router-outlet element? I was getting the same error, fixed it with that.

    • @shaunb
      @shaunb 5 лет назад

      Ricardo Zanardo I confirmed that I have added that. Maybe it’s related to material?

    • @metalllus
      @metalllus 5 лет назад +1

      @@shaunb same here, not working with site using angular material, did you find a solution?

  • @yassinekhe466
    @yassinekhe466 4 года назад +2

    thanks for the tuto but How I can use the same animation only between some components and not all of the application?

  • @akbaralimajeed
    @akbaralimajeed 4 года назад

    Excellent but Just relax man

  • @avihusiso6888
    @avihusiso6888 8 месяцев назад

    a question.. when i apply the slide transition , some elements jump in the air untill the slide transition ends and then they jump back to their place.. how do i fix this ?

  • @ThiagoLucioBittencourt
    @ThiagoLucioBittencourt 5 лет назад +1

    Good video, but...... talk to fast, don't show some pieces of code (imports too). But... It's a great video anyway. Thanks. In your Site, the write version solves this problem. One more point with total 10 :)

  • @carniattos
    @carniattos 5 лет назад +2

    Awesome video!! Could this also be used with lazy loaded routes?

    • @Fireship
      @Fireship  5 лет назад

      Yes, it should work with lazy routes out of the box :)

  • @ameerpappay6782
    @ameerpappay6782 5 лет назад +1

    slider animation not working if consecutive routes has same animation left or right
    why its so?

  • @MarkStatkus
    @MarkStatkus 3 года назад

    I tested this out.. chrome fairly smooth, other browsers 1 to 2 FPS. I wish there was a easier way to do this using GSAP or just straight CSS.

  • @ahmadartcraft9235
    @ahmadartcraft9235 3 года назад

    Awesome tutorial.... :)

  • @kennethkwakye-gyamfi4765
    @kennethkwakye-gyamfi4765 5 лет назад +37

    Slow down 😢

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 4 года назад +1

      Play on 0.75x

    • @randomlee101
      @randomlee101 Год назад

      Lol I kept dragging it back. The video was helpful though

  • @saisreenivas2227
    @saisreenivas2227 5 лет назад

    Thanks for sharing lot of information

  • @kamleshmerugu7621
    @kamleshmerugu7621 5 лет назад

    Way to go, looking forward for some more awesome videos

  • @CodingCatDev
    @CodingCatDev 5 лет назад

    Beautiful job as always Jeff! I was just working on page flips for the same. Are there any suggestions on when to do animation work using CSS directly vs using Angular Animations?

    • @Fireship
      @Fireship  5 лет назад +1

      I would use CSS for simple isolated animations like a button hover, but ng animations for things tied to the state of the app, i.e the router state.

    • @CodingCatDev
      @CodingCatDev 5 лет назад

      @@user-if1de8pt2j oh that is interesting I will have to throw some Lorem Ipsum in and see what happens!

  • @ApexHighlightReels
    @ApexHighlightReels 5 лет назад +1

    It works very beautifully on development ... but does not work on production (ng s/b --prod)

  • @metalvarez1
    @metalvarez1 5 лет назад +1

    is there a way to implement his on an ionic 4 app ? the official ionic docs don't mention any of this, and the documentation page of ion-router-outlet is pretty obscure, it just says that it supports animationBuilder animations, just that, not a word on hwo to implement it.

  • @kokiiito
    @kokiiito 5 лет назад

    love this! thanks!

  • @swastikdas9169
    @swastikdas9169 10 месяцев назад

    why dont you have word wrap turned on ? half my time was wasted just trying to figure out where the heck the slider came from

  • @space_monkey125
    @space_monkey125 5 лет назад

    Awesome video very helpful

  • @islamelsayed7263
    @islamelsayed7263 2 года назад

    Hello, why this error console (.Unable to process animations - returned zero elements ) !?

  • @LonliLokli
    @LonliLokli 3 года назад

    If you have eg 5 routes, all this isRight or isLeft will not work as you have to know both source and destination position on the screen

  • @will_abule
    @will_abule 5 лет назад

    terrific!

  • @themindstorm9947
    @themindstorm9947 5 лет назад +1

    Is anyone else getting this error?
    ERROR in app/app.component.ts(20,5): Error during template compile of 'AppComponent'
    Function calls are not supported in decorators but 'slideTo' was called in 'slider'
    'slider' calls 'slideTo'.

    • @themindstorm9947
      @themindstorm9947 5 лет назад +4

      I have a quick fix for anyone experiencing the same issues:
      - create three variables: optional, toTheLeft, and toTheRight
      - assign these variables instead of the slideTo('left') or slideTo('right') functions
      See the full code here: pastebin.com/H1CKMvw5

    • @otaviofrank5902
      @otaviofrank5902 5 лет назад +1

      @@themindstorm9947 Thank you!

    • @HelpUsBelieve
      @HelpUsBelieve 5 лет назад +1

      @@themindstorm9947 Thanks

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 4 года назад

      @@themindstorm9947 thanks

  • @cholasimmons
    @cholasimmons Год назад

    nothing worked for me, maybe coz I have nested routes?

  • @xenon4602
    @xenon4602 4 года назад +1

    does he make all of his videos like ctrl + z ?

  • @theobellash6440
    @theobellash6440 5 лет назад

    WooooWooonderfull

  • @AlekseyNew
    @AlekseyNew 5 лет назад

    Wow! Cool! Thanx!

  • @sagnikpradhan3594
    @sagnikpradhan3594 5 лет назад

    Here I am sitting and using ejs while seeing these kind of videos. LOL.

  • @Agus013013
    @Agus013013 4 года назад

    I come from a plain JS background, I am just starting to build with AngularJS however this whole typescript and module stuff I don't know where to start. Would anyone point me in the right direction linking me to a resource, I want to start doing exactly what Jeff is doing on this video asap.

  • @meenakshinegi
    @meenakshinegi 5 лет назад

    Thanks

  • @sonoftroy8572
    @sonoftroy8572 5 лет назад

    This is awesome! What can I do to get the deep understanding of code the way you do

    • @Fireship
      @Fireship  5 лет назад +2

      Code everyday and try to build cool stuff :) Then try teach it by blogging or making videos

  • @theyja1
    @theyja1 3 года назад

    that last stepper animation not working for me
    please help me!
    animations:[
    fader,
    slider,
    transformer,
    stepper,

    ],
    app.routing.modules -> data:{animation:'isRight'}
    route-animation->
    export const stepper =
    trigger('routeAnimations', [
    transition('* *', [
    query(':enter, :leave', [
    style({
    position: 'absolute',
    left: 0,
    width: '100%',
    }),
    ]),
    group([
    query(':enter', [
    animate('2000ms ease', keyframes([
    style({ transform: 'scale(0) translateX(100%)', offset: 0 }),
    style({ transform: 'scale(0.5) translateX(25%)', offset: 0.3 }),
    style({ transform: 'scale(1) translateX(0%)', offset: 1 }),
    ])),
    ]),
    query(':leave', [
    animate('2000ms ease', keyframes([
    style({ transform: 'scale(1)', offset: 0 }),
    style({ transform: 'scale(0.5) translateX(-25%) rotate(0)', offset: 0.35 }),
    style({ opacity: 0, transform: 'translateX(-50%) rotate(-180deg) scale(6)', offset: 1 }),
    ])),
    ])
    ]),
    ])
    ]);

  • @divinedela9125
    @divinedela9125 5 лет назад +1

    number 1

  • @Skylark9704
    @Skylark9704 5 лет назад +4

    what if your router outlet is not in app-component?

    • @alexandergerlach4579
      @alexandergerlach4579 4 года назад

      mine is in header component cause my header wraps the whole app because of angular-material. i just put all the logic in the header.ts file and it works.

  • @JuanCruz-uk3qi
    @JuanCruz-uk3qi 4 года назад

    Hi, how can i add this transitions/animations to another routing ? I havnt got all the components in AppRoutingModule. Thanks!

  • @MedracZ
    @MedracZ 4 года назад

    Anyone else having issues with overflow when routing to a new page?

  • @minigeek
    @minigeek 3 года назад

    someone tell this man to demonstrate live instead of coding by copy pasting.. it literally makes me think, I know nothing of angular :/

  • @jeremysistrunk3742
    @jeremysistrunk3742 3 года назад

    How do you ensure smooth animations using resolveGuard?

  • @barjosa31blogspot83
    @barjosa31blogspot83 5 лет назад

    It would be great if you just slow down a litttle bit while speaking and moving on. Will appreciate this!
    Still, deserved like!

  • @surajankita1
    @surajankita1 4 года назад

    on default routing , animation not working?

  • @ashrafkamal1806
    @ashrafkamal1806 4 года назад

    @Fireship will this work on ionic angular? ionic v4

  • @belabztech1055
    @belabztech1055 4 года назад

    Beautiful tutorial with sweet pace, shirt, smart and interesting,
    PS: I love your Editor Font, what font is please?
    Keep Rocking,

  • @ankitabhatt4359
    @ankitabhatt4359 4 года назад

    Can anybody please help me out . I am facing this error `query(":enter")` returned zero elements. (Use `query(":enter", { optional: true })` if you wish to allow this.)

    • @Mike-qg1we
      @Mike-qg1we 3 года назад +2

      Hi, yesterday I've been struggling with these errors - what helped me was changing this -> [@routeAnimations]="prepareRoute(outlet)" into that -> [@fadeInAnimation]="outlet.isActivated ? outlet.activatedRoute : ''" and discarding the function. I know this will leave you with only one animation for route change but this was my goal anyway, and you always can wrap it in a function. Hope someone will find this helpful ;) (btw fadeInAnimation is what my animation is called in route-animations.ts)

  • @wisesa_dev
    @wisesa_dev 5 лет назад

    Hmmm nice

  • @NitrosS
    @NitrosS 4 года назад +2

    I´m in 0.75 speed

  • @kellvivar
    @kellvivar 5 лет назад

    what is the Font of your editor?

  • @Boilinglemon
    @Boilinglemon 5 лет назад

    Hi Jeff,
    I've followed your tutorial and the animations work great when using ng serve, but when I try to ng build --prod, I get this error:
    ERROR in src\app
    ecipe-builder
    ecipe-builder.component.ts(9,16): Error during template compile of 'RecipeBuilderComponent'
    Reference to a non-exported function in 'slider'
    'slider' contains the error at src\app
    ecipe-builder
    oute-animations.ts(37,10)
    Any idea why this might be the case for building to production?
    Thanks

    • @romaincrevecoeur5952
      @romaincrevecoeur5952 5 лет назад

      I have the issue if you happen to fix it

    • @HelpUsBelieve
      @HelpUsBelieve 5 лет назад

      This is happening to me as well.

    • @Boilinglemon
      @Boilinglemon 5 лет назад

      Romain Crevecoeur I still haven’t fixed it, I’ve just been building without -prod 😕

    • @romaincrevecoeur5952
      @romaincrevecoeur5952 5 лет назад

      I did animations with CSS instead. It's not totally what i exepected but it's good enough

  • @jorgenorena727
    @jorgenorena727 4 года назад

    Why so hurry? Please slow down...

  • @imaliazhar
    @imaliazhar 5 лет назад +1

    What VS code theme are you using?

  • @veshrajjoshi1
    @veshrajjoshi1 4 года назад

    Content is very useful, appreciate it. One suggestion - make video slower which would be more effective. You are in fast-forward mode and sounds like "lfjdkljfsldflskdjfklsdjfl".

  • @sisterhood6022
    @sisterhood6022 5 лет назад +1

    Awesome content (thank you!).
    But why are you in **such** a hurry ALL-THE-TIME ;-) ?

  • @ciprianlupsa557
    @ciprianlupsa557 4 года назад

    The pace is too fast

  • @marcellokabora
    @marcellokabora 5 лет назад

    Looks very complex :(

  • @ninipop82
    @ninipop82 5 лет назад

    These videos are good. But also very fast....

  • @darshangowda309
    @darshangowda309 5 лет назад +1

    first :P