CSS scroll-driven animations

Module CSS scroll-driven animations cung cấp chức năng xây dựng trên module CSS animationsWeb Animations API. Nó cho phép bạn animate các giá trị thuộc tính theo timeline dựa trên cuộn thay vì timeline tài liệu dựa trên thời gian mặc định. Điều này có nghĩa là bạn có thể animate một phần tử bằng cách cuộn phần tử đó, scroll container của nó, hoặc phần tử gốc của nó, thay vì chỉ bằng sự trôi qua của thời gian.

Scroll-driven animations hoạt động

Bạn có thể xác định scroller kiểm soát animation bằng cách đặt tên animation hoặc dùng hàm scroll().

css
main {
  scroll-timeline: --main-timeline;
}

div {
  animation: background-animation linear;
  animation-timeline: scroll(nearest inline);
}

div::after {
  animation: shape-animation linear;
  animation-timeline: --main-timeline;
}

Cuộn phần tử theo chiều inline để xem màu nền thay đổi. Cuộn dọc để xem nội dung được tạo ra di chuyển, xoay và thay đổi màu sắc.

Tham chiếu

Thuộc tính

Kiểu dữ liệu và giá trị

Hàm

Interface

Hướng dẫn

Scroll-driven animation timelines

Scroll-driven animation timeline và cách tạo scroll-driven animation.

Timeline range names

Kiểu dữ liệu <timeline-range-name>: Hiểu các tên timeline range khác nhau.

Khái niệm liên quan

Đặc tả

Specification
Scroll-driven Animations

Xem thêm