Upgrade to Pro — share decks privately, control downloads, hide ads and more …

View Transition API and scroll-driven animation...

Sascha Lehmann
November 12, 2024
16

View Transition API and scroll-driven animations: game changers for hybrid app development

The rapid development of web APIs (keyword: Project Fugu) has increasingly closed the gap that existed between progressive web apps (PWA) or hybrid development approaches and native apps. Visually, they are also barely distinguishable from native apps. However, when it comes to animations, native apps have always been one step ahead thanks to the availability of native animation APIs. Until now, complex animations such as container transforms were practically impossible to implement in web apps without immense effort.

That’s right. They WERE. This gap can now also be closed thanks to the new View Transition API and Scroll-Driven Animations. And the best thing about it: everything is done almost exclusively using CSS. Curious? Then Sascha Lehmann from Thinktecture will give you an overview of the new APIs, how you can use them effectively in your project and where their limits lie.

Sascha Lehmann

November 12, 2024
Tweet

More Decks by Sascha Lehmann

Transcript

  1. What happens behind the scenes User Perspective Browser Perspective Screenshot

    (old) Perform DOM changes Live-View (new) Crossfade Old -> New startViewTransition(…) View-Transition-API and Scroll-Driven Animations Gamechanger for hybrid app-development Process of a View-Transition
  2. Pseudo DOM Tree • New Top-Layer • Default animation: Cross-fade

    • Elements only exist during the View-Transition Process of a View-Transition View-Transition-API and Scroll-Driven Animations Gamechanger for hybrid app-development
  3. Pseudo Elemente ::view-transition Overlay root element that sits above all

    other DOM elements in order to exclude genetic interference ::view-transition-group Root-Element of the View-Transition ::view-transition-image-pair Container of the before and after snapshot ::view-transition-old/-new Elements that show the before and after DOM states as a Snapshot or live view Jedes Pseudo-Element ist separat per CSS stylebar Process of a View-Transition View-Transition-API and Scroll-Driven Animations Gamechanger for hybrid app-development
  4. The snapshots are ”just” images – Not real DOM Elements

    ATTENTION! Has no effect! View-Transition-API and Scroll-Driven Animations Gamechanger for hybrid app-development
  5. Browser Stylesheet Where does the magic come from? View-Transition-API and

    Scroll-Driven Animations Gamechanger for hybrid app-development
  6. What happens behind the scenes „Cutting out“ additional parts User

    Perspective Browser Perspective Screenshot (old) Perform DOM changes Live-View (new) Crossfade Old -> New startViewTransition(…) View-Transition-API and Scroll-Driven Animations Gamechanger for hybrid app-development
  7. What happens behind the scenes „Cutting out“ additional parts User

    Perspective Browser Perspective Perform DOM changes Live-View (new) Crossfade Root - animiere Header separat startViewTransition(…) Screenshot-Header (old) View-Transition-API and Scroll-Driven Animations Gamechanger for hybrid app-development
  8. Default – Document Timeline Animation-Timelines • Represents the default Document-Timeline

    • Time progresses continuously from the time the document was initially loaded View-Transition-API and Scroll-Driven Animations Gamechanger for hybrid app-development
  9. Scroll Progress Timeline • Scroller: Element, to determine the scroll

    progress • nearest (default) • root • self • Axis: Scroll-axis that is used • block (default) • inline • X • Y Animation-Timelines • Time advances by scolling a scollable element (scroller) • The scroll position is converted into percentage values from 0 - 100 View-Transition-API and Scroll-Driven Animations Gamechanger for hybrid app-development
  10. View Progress Timeline • Axis: Scroll-axis that is used •

    block (default) • inline • X • Y • Inset: To define insets or outsets that determine when the element is in the viewport • start (top-offset) • end (bottom-offset) Animation-Timelines • Time progresses through the visibility of an element (subject) • The visibility of the element in the viewport is converted into percentage values from 0 - 100 • Is always tracked depending on the next best scrollable element View-Transition-API and Scroll-Driven Animations Gamechanger for hybrid app-development
  11. View Progress Timeline • Alternative spelling for view( start end)

    • Additional key words for animation-range • entry: Equals 0% • exit: Equals 100% • Additional key words for animation-range-start and animation-range-end • cover: As soon as only part of the element is visible in the viewport • contain: The entire element must be visible in the viewport • Very suitable, for example, for cases with images of different heights Animation-Timelines View-Transition-API and Scroll-Driven Animations Gamechanger for hybrid app-development
  12. A look … … into the future View-Transition-API and Scroll-Driven

    Animations Gamechanger for hybrid app-development