跳过导航
Probably old news now, but the CSS View Transition API is SUPER cool!
0:00 / 0:29

Probably old news now, but the CSS View Transition API is SUPER cool!

Devon Govett

@devongovett4.2万 位关注者

在 X 上查看
1,105 个赞下载原帖

98,021 次观看

Probably old news now, but the CSS View Transition API is SUPER cool! Entry/exit layout animations like this used to be super complicated or require giant libraries. Now it's like 2 lines of JS, and a few lines of CSS if you want to customize the animation. Amazing! 🤯

10 条评论

评论来自 X (Twitter) 上的原帖

  • Devon Govett 的头像

    @devongovett

    Code:

    56 个赞

  • Kushagra Gour @css_battle 的头像

    @chinchang457

    yes! And here's a demo without the performance hit of using flushSync

    4 个赞

  • Devon Govett 的头像

    @devongovett

    flushSync is fine. This is the exact type of thing it is designed for. Actually in this case it may even be faster. When startViewTransition is called it freezes the DOM to take a snapshot. Flushing synchronously reduces the time the page is frozen because updates occur immediately rather than waiting unnecessarily.

    8 个赞

  • Jim Meyer 的头像

    @jimmeyer

    Super clean. I immediately tried clicking the add button before the current transition had finished, finding that it then ignores that click. Limitation of freezing the DOM, or is there a way to stack the transitions?

    2 个赞

  • Devon Govett 的头像

    @devongovett

    Yeah it’s a limitation of the current API but I think the spec authors are aware of it so hopefully it’ll get better eventually

    4 个赞

  • Mostafa 的头像

    @mustafaabobakr_

    Is using the "flushSync" recommended for lists?

    1 个赞

  • Devon Govett 的头像

    @devongovett

    In this case it’s required for the view transition to take effect. The DOM updates have to occur inside that callback

    4 个赞

  • Ismal Zikri 的头像

    @ZikriIsmal

    can you drop that link pls? pretty excited to try it ...

  • Devon Govett 的头像

    @devongovett

    No problem

    1 个赞

  • Nate Smith 的头像

    @nasm423

    Very very cool!