Web animation gotchas - HTTP 203

Поділитися
Вставка
  • Опубліковано 9 лис 2020
  • 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/ChromeDevs
    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”

  • @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. 🙏

  • @RexPan
    @RexPan 3 роки тому +10

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

  • @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).

  • @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. 👍

  • @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 :)

  • @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.

  • @juliasemenova4000
    @juliasemenova4000 3 роки тому

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

  • @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!

  • @Textras
    @Textras 3 роки тому +1

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

  • @shamsartem
    @shamsartem 3 роки тому

    This is so cool. The best channel for tech knowledge

  • @pictureus
    @pictureus 3 роки тому +1

    Great video as always :)

  • @EmielZuurbier
    @EmielZuurbier 3 роки тому

    Really learned something here. Thanks guys!

  • @wmhilton-old
    @wmhilton-old 3 роки тому

    Fantastic stuff. I did not know half of this!

  • @filipbystricky7301
    @filipbystricky7301 29 днів тому

    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 😎

  • @ASDevelopersTutorials
    @ASDevelopersTutorials 3 роки тому

    Awesome stuff 😎

  • @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.

  • @omri9325
    @omri9325 3 роки тому

    I ❤ these videos

  • @DisfigurmentOfUs
    @DisfigurmentOfUs 2 роки тому

    Thank you it was useful and fun!

  • @JacobCanote
    @JacobCanote 3 роки тому

    You 2 are Z'Best!

  • @robinparadise
    @robinparadise 3 роки тому

    So good 👍

  • @Cookie_Wookie_7
    @Cookie_Wookie_7 3 роки тому

    Can we please get some more HTTP 203 I miss these

  • @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"!

  • @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 🤦‍♂️

  • @patroclus8796
    @patroclus8796 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 ua-cam.com/video/cCOL7MC4Pl0/v-deo.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.

  • @yoshmarklund
    @yoshmarklund 3 роки тому +2

    Paul

  • @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 :)

  • @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

  • @DenisTRUFFAUT
    @DenisTRUFFAUT 3 роки тому

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

  • @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.

  • @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.

  • @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.

  • @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

  • @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'.

  • @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

  • @DennisJ42
    @DennisJ42 3 роки тому

    Go go Chrome Developpeerrsss!

  • @ZIYAD91
    @ZIYAD91 3 роки тому

    For the algo

  • @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

  • @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

  • @wick4300
    @wick4300 3 роки тому

    Where’s Monica?

  • @matteobagni1235
    @matteobagni1235 3 роки тому

    Where is aerotwist!!!

  • @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?? ua-cam.com/video/IskiTVqHp18/v-deo.html

    • @write2sampath1
      @write2sampath1 3 роки тому

      @@jakearchibald that sticker confused me . 😂

  • @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.

  • @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.

  • @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.

  • @kriscavitt3479
    @kriscavitt3479 3 роки тому

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

  • @marjak93
    @marjak93 3 роки тому +1

    first

  • @Theraot
    @Theraot 3 роки тому

    8:21 Visibility API to the rescue?

    • @jakearchibald
      @jakearchibald 3 роки тому

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

  • @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.

  • @surajdan521
    @surajdan521 3 роки тому

    First to comment