Web animation gotchas - HTTP 203

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • Fading something in, and fading something out - sounds simple right? Unfortunately not! Jake & Surma talk through the various gotchas of animating the web, and how to work around them.
    Using CSS transitions → goo.gle/2TXTUCB
    Using CSS animations → goo.gle/3et8gEq
    The web animation API → goo.gle/3mXbV0C
    getAnimations → goo.gle/3oXMLk4
    commitStyles → goo.gle/38d6PsN
    Event listeners and garbage collection → goo.gle/32c4TNd
    Spec discussions → goo.gle/3k1zbIE
    The final animateTo function → goo.gle/363WVHn
    JavaScript animation libraries:
    jQuery → goo.gle/34XEowU
    Greensock → greensock.com/
    AnimeJS → animejs.com/
    The old library Jake made (don't use it) → goo.gle/34ZFGaU
    Other videos in the series → goo.gle/2wneQLl
    Subscribe to Google Chrome Developers here → goo.gle/Chrome...
    Also, if you enjoyed this, you might like the HTTP203 podcast! → goo.gle/2y0I5Uo

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

  • @adamtolbert1296
    @adamtolbert1296 3 года назад +20

    @Surma misenglish is my new word of the day haha I think you combined “true to form” and “close to home”

  • @RexPan
    @RexPan 3 года назад +10

    02:20 CSS Transition
    06:56 CSS Animation
    08:32 Web Animation API
    14:26 animateTo

  • @MartinodF
    @MartinodF 3 года назад +14

    Fantastic video! I feel like episodes like this, where you share more obscure issues you've encountered and solved in the past, are just pure golden. 🙏

  • @justintaddei
    @justintaddei 3 года назад +3

    Thank you for always creating such incredible content! This series, in combination with SuperCharged, has been the single greatest influence over the quality of my work. I would not be half the developer that I am today without the two of you (and Pual).

  • @filipbystricky7301
    @filipbystricky7301 3 месяца назад

    Hi! Great video. Would love to see the admin add a pinned comment linking to the new view transitions API and how your demos would be updated to use it. My understanding is: we used to have old transitions, then we got animation-based transitions, and now we have view-transitions and the ability to animate discrete properties. Maybe there's already a newer video on your channel you could link to?

  • @mustafwm
    @mustafwm 3 года назад +1

    again THANK YOU ..another awesome video
    didn't know about .animate! ..cool 😎

  • @Textras
    @Textras 3 года назад +1

    Just summarized half a year of work. Fine, a year.

  • @manuelroth7700
    @manuelroth7700 3 года назад +1

    I would love to see an episode on advanced animations on the web like scroll based and timeline based animations. There are many libraries like greensock, animejs, scrollmagic ect. that help with this advanced animation use cases. I would love to know if it would be possible to replace them with modern web apis like the web animation api.

    • @dassurma
      @dassurma 3 года назад +1

      Web Animations API has a dedicated timeline type and a scroll timeline now :)

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

    5:20 I really though it was the spelling of transitioned that was the weirdness! Until I realized it was "transition end", not "transitioned"!

  • @ChrisPizzinato
    @ChrisPizzinato 3 года назад +1

    Great video guys! I've always struggled with animations and it's comforting that others have been caught by the gotchas over the years. Thanks for the explanation on the different methods and a suggested approach to animating. 👍

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

    Is the getComputedStyle() method slower than the double-RAF?
    Will the browser synchronously wait for the next frame?

    • @jakearchibald
      @jakearchibald 3 года назад +1

      It doesn't wait for the next frame, it just performs a style calculation. It shouldn't be a problem unless you've got lots of code that invalidates styles and recalculates them in a single frame.

  • @yoshmarklund
    @yoshmarklund 3 года назад +2

    Paul

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

    Loved this. Unbelievable how much I learned from the http 203 casts over the past few years. You guys definitely contributed immensely to my transition from an 'ok' dev to a decent web platform Developer who really keeps an eye open for optimal implementation of Features with baked in APIs rather than some jankie DIY JS.
    I really owe you guys one :)

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

    OH MY GOD that small comment about having to use rAF twice was such a mind blown to me, I never understood why one didn't work, and usually ended up giving up and using wait(1000/60) or something similar 🤦‍♂️

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

    In the spirit of "first": 1337 views! That aside - thanks guys, for making these videos. They're little nuggets of pure gold. Looking forward to seeing your in-person banter. Also missing Supercharged! Props on the callback.

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

    Thank you it was useful and fun!

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

    It's really amazing! Thanks for the video) Interesting gotchas, especially the one with fill mode

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

    Another animation gotcha: if you're animating block height (yes that's not performant but sometimes it should be done) and that animation is triggered by a button contained within that block - don't forget to remove focus from that button (event.target.blur()), otherwise the whole screen would scroll with that button because it's still in focus.

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

    I started to create a bit of tooling to make the web animation API work for me. The whole concept of "fill" is very unintuitive to me, and I have a 20+ year history of scripted animations.

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

    Where’s Monica?

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

    I just encountered this issue last week! Instead of using Animation API, I am using the traditional modify class list method, which ends up with multiple mid-state classes. Great video!

  • @pictureus
    @pictureus 3 года назад +1

    Great video as always :)

  • @patroclusTractors
    @patroclusTractors 3 года назад +1

    Hands off, gsap is the best animation api out there nothing that comes even close it .

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

      I used gsap a lot when doing the slides for my event loop talk ruclips.net/video/cCOL7MC4Pl0/видео.html. I don't think it has a great API, but it does work. I might use AnimeJS these days just because it's much smaller.

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

      @@jakearchibald I agree with sam, nothing comes even close to GSAP, which shouldn't surprise anyone as it had almost 20 years to mature. A lot of realworld friction polished it into shape.

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

      @@herrbasan Fair enough. Personally the "20 years" has resulted in a lot of baggage, both in terms of API design and implementation. I've used it in slides, but I think I'd avoid it in favour of a lighter alternative.

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

    Can we please get some more HTTP 203 I miss these

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

    I didn't see it mentioned, but in my experience I've had animations such as opacity fades (or anything really) kept in CSS classes like ".fade-in"
    And then upon user interaction I use javascript to append the class ".fade-in" to the div that needs it. And later ".fade-in" can be swapped to ".fade-out" or various other animations. The animations are always CSS classes and JS is used to trigger each one.
    I personally haven't run into any issues doing it this way. Are there advantages to the method in the video over the one I'm used to?

    • @jakearchibald
      @jakearchibald 3 года назад +1

      This was already mentioned in another comment. If you use class names, then you're back to using events for completion, and probably back to using fill-forwards, then you're back to all the issues I mentioned in the episode.

  • @marjak93
    @marjak93 3 года назад +1

    first

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

    Really learned something here. Thanks guys!

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

    Hi, why there is a photo o the guy Paul Lewis marked with "Gone but not forgotten" ? To be clear, I am not offended or something, but it seems to happened something to that person. But I didn't find any information announced about that.

    • @jakearchibald
      @jakearchibald 3 года назад +1

      Paul used to be on this show until he moved to another team and Surma stepped in.

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

      @@jakearchibald looks like, it means something else. Got distracted and instead of watching the video, i went on to searching about him.

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

      @@leojino yeah we've removed it from the newer episodes

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

      @@jakearchibald that’s good. And I found his latest tweets, so all good

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

    Wow. So much things I still don't know.

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

    This is so cool. The best channel for tech knowledge

  • @wmhilton-old
    @wmhilton-old 3 года назад

    Fantastic stuff. I did not know half of this!

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

    Love the video. If you didn't need to use fill to get the final values wouldn't the flash of wrong css be an issue again?

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

      I'd like some option like commitOnFinish: true

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

    Or just use Svelte. ‘transition:fade’. Done.

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

      Although I talk about fade specifically, I'm talking more about general animation principles. The solution covered works for many different kinds of animation, even multikeyframe and off the main thread.

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

    Greensocks solved these issues already I guess, since I've not had any of these issues in the years I've used it.

    • @jakearchibald
      @jakearchibald 3 года назад +2

      Right, but that's 25k+ of script you might not need

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

    Go go Chrome Developpeerrsss!

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

    I would recommend doing `options: { fill: 'both', ...options }` that way if someone passes in their own fill on purpose, it will override yours.

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

      hm but if they don't use 'forward' or 'both', the method will not work as intended

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

      @@jakearchibald could have 'disco' in the future. I just think it would be annoying if I pass in 'fill: foward' because it's exactly the way I want it to work, and it gets overwritten with 'both'.

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

    Where is aerotwist!!!

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

    Isn‘t it, in most Cases, better to just add and remove classes?

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

      I don't think so. If you use class names, then you're back to using events for completion, and probably back to using fill-forwards, then you're back to all the issues I mentioned in the episode.

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

    Hey, why not just add a option in the animation api to just apply the style at the end of animation?
    And by the way, really fun videos!!

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

      That's the solution I'd like to see too. There's some discussion of it in the spec issues. I'm less sure of what should happen if the animation is cancelled, but I guess that could be an option too.

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

      @@jakearchibald could be an event flag indicating finished but canceled similar to events we have for keyup and keydown

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

    You 2 are Z'Best!

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

    I ❤ these videos

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

    So good 👍

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

    Why is there a sticker with Paul, gone but not forgotten ? Is he really left google ?

    • @jakearchibald
      @jakearchibald 3 года назад +3

      Paul used to be a presenter on HTTP 203. OR HAVE YOU FORGOTTEN?? ruclips.net/video/IskiTVqHp18/видео.html

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

      @@jakearchibald that sticker confused me . 😂

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

    It is quite astounding that in 2020 we still haven't achieved Macromedia Flash 5 animation prowess which was back in 2000.

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

      I don't think that's the case. Flash devs relied heavily on Greensock for anything beyond the simplest animation. And I don't think Flash ever had anything like compositor driven animations.

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

      Even on this video you have so eloquently highlighted the quirks and perks of web animation ever since we moved away from flash.
      With Flash's timeline, visual tools and animation attachments to movieclips, the process of creating animated UI experiences was more polished and straight forward. The collaboration between programmer and web designer felt natural and streamlined. If we think about it Flash was a single page application with enhanced rich media capabilities and visual tooling in an era of static html pages. The current paradigm feels like "hacking" on that old static dom elements of the previous century browser :).
      Anyways, just my two cents from an old timer who was around during the rise and fall of that flashy web.

    • @jakearchibald
      @jakearchibald 3 года назад +1

      I used to be a flash developer too. The browser runtime is much better than the flash runtime in terms of performance, but yeah, the web hadn't seen anything as good as the Flash IDE.

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

      Indeed, performance was the main culprit to it's downfall. I really enjoyed the "flash" flashback in the video (and here). cheers

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

    Awesome stuff 😎

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

    For the algo

  • @hobbyturystaSEO
    @hobbyturystaSEO 3 года назад +1

    I feel some power in the INTRO. 20 years of experience to make one web animation function, hmmm... That's a topic for a book or blog post at least. Let's think where we can be in 20 years with WEB ANIMATION. I can estimate that WEB animations will be accessible via some kind of API on the VIDEO screen on the car screen. Web animations can help people who work in the transport industry on other continents like European container ships crew in Asia, or Asian cabin crew in Africa. The WEB TRANSPORT ANIMATION is the future where we all going to.

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

    I find myself missing the days of flash and silverlight. Back when the web was cool.. js animation tools, do any exist?

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

    8:21 Visibility API to the rescue?

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

      The visibility API is more about page visibility than element visibility.

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

    First to comment

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

    Loving that Limited edition Lagavulin in the background, I have one myself👌

    • @jakearchibald
      @jakearchibald 3 года назад +1

      Yeah! I was bought it for my birthday. I thought it'd be average because it's a tie-in, but I really really enjoyed it.