I was playing around with CSS scroll-driven animations a little bit today and made a neat heart rate progress indicator using only CSS. As you scroll down the page the heart rate reading progresses.
animation-timeline is not currently supported in all browsers, including Firefox, so if the example below doesn't work, that's why.
See the Pen CSS scroll-driven ekg animation by Zach Patrick (@zpthree) on CodePen.
This is obviously a very rudimentary example of what can be done using scroll-driven animations.
The HTML is pretty simple. It's just a heart rate SVG and a skull that shows up when the heart rate stops.
html
I did add a little bit of JavaScript just so I could get the length of the SVG's path and set the SVG's stroke-dasharray and stroke-dashoffset values dynamically.
javascript
The path of the SVG starts completely hidden and, as you scroll, gets drawn until it's completely visible. The stroke-dashoffset is the amount of the path that still needs drawn, so animating that to zero simulates the heart rate.
Then I used the CSS scroll() function to hook into the page's scroll bar and animate the heart rate based on the scroll bar position.
css
Unfortunately, the animation-timeline property that enables this CSS-only approach is currently not yet available in all browser.