{"id":692,"date":"2024-01-30T17:11:58","date_gmt":"2024-01-30T23:11:58","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=692"},"modified":"2024-01-30T17:11:58","modified_gmt":"2024-01-30T23:11:58","slug":"a-scroll-driven-animation-with-a-duration","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/a-scroll-driven-animation-with-a-duration\/","title":{"rendered":"A Scroll-Driven Animation&#8230; with a Duration"},"content":{"rendered":"\n<p><a href=\"https:\/\/ryanmulligan.dev\/blog\/scroll-triggered-animations-style-queries\/\">Ryan Mulligan digs into<\/a> a <a href=\"https:\/\/codepen.io\/jh3y\/pen\/qBgRLxb\">Jhey Tompkins Pen<\/a> and discovers a neat little trick involving <em>two<\/em> @keyframe animations. The first is a &#8220;trigger&#8221; animation that triggers when a certain element comes into view, and flips a <code>--trigger<\/code> custom property. Via a Style Query, that triggers the actual animation. <\/p>\n\n\n\n<p>Why bother? Scroll-driven animation durations are, well&#8230; scroll&#8230; driven. This trick severs that, so you can do stuff like &#8220;when this element comes into view, run this little animation over 600ms&#8221;, entirely in CSS.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/codepen.io\/jh3y\/pen\/qBgRLxb\">Jhey&#8217;s demo<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/codepen.io\/hexagoncircle\/pen\/wvOPmGO\">Ryan&#8217;s demo<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Ryan Mulligan digs into a Jhey Tompkins Pen and discovers a neat little trick involving two @keyframe animations. The first is a &#8220;trigger&#8221; animation that triggers when a certain element comes into view, and flips a &#8211;trigger custom property. Via a Style Query, that triggers the actual animation. Why bother? Scroll-driven animation durations are, well&#8230; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":694,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29],"tags":[7,57],"class_list":["post-692","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-beat","tag-css","tag-scroll-driven-animations"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/01\/scroll-driven-toggle-thumb.jpg?fit=1000%2C500&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=692"}],"version-history":[{"count":1,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/692\/revisions"}],"predecessor-version":[{"id":693,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/692\/revisions\/693"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/694"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}