animation-range.css (1173B)
1 .flex { 2 display: flex; 3 } 4 5 .flex > div { 6 position: relative; 7 height: 160px; 8 margin: 0 10px; 9 } 10 11 .scroller { 12 width: 100px; 13 height: 100px; 14 overflow: auto; 15 border: 1px solid black; 16 } 17 18 .subject { 19 view-timeline-name: --view; 20 width: 20px; 21 height: 20px; 22 margin: 100px auto; 23 background: green; 24 } 25 26 .meters { 27 position: absolute; 28 left: 0; 29 top: 110px; 30 height: 50px; 31 } 32 33 .meters > div { 34 display: flex; 35 align-items: center; 36 } 37 38 @keyframes active-interval { 39 0% { opacity: 1; } 40 100% { opacity: 1; } 41 } 42 43 .meter { 44 width: 50px; 45 position: relative; 46 border: 2px solid black; 47 height: 5px; 48 overflow: clip; 49 opacity: 0.4; 50 animation: active-interval linear; 51 animation-timeline: --view; 52 } 53 54 @keyframes slide-in { 55 0% { transform: translateX(-100%)} 56 100% { transform: translateX(0%)} 57 } 58 59 .bar { 60 width: 100%; 61 height: 100%; 62 background: blue; 63 transform: translateX(-100%); 64 animation: slide-in linear; 65 animation-timeline: --view; 66 } 67 68 .spacer { 69 height: 400px; 70 } 71 72 .contain .bar, .contain .meter { 73 animation-range: contain; 74 } 75 76 .entry .bar, .entry .meter { 77 animation-range: entry; 78 } 79 80 .exit .bar, .exit .meter { 81 animation-range: exit; 82 }