{"id":429,"date":"2022-09-28T16:08:57","date_gmt":"2022-09-28T08:08:57","guid":{"rendered":"https:\/\/blog.osvlabs.com\/?p=429"},"modified":"2022-09-28T16:10:59","modified_gmt":"2022-09-28T08:10:59","slug":"%e5%86%99%e6%bb%9a%e5%8a%a8%e5%8a%a8%e7%94%bb%e4%b8%8d%e6%ad%a2%e6%96%b9%e4%be%bf%e4%b8%80%e7%82%b9%e7%82%b9%ef%bc%8ccss%e6%9c%aa%e6%9d%a5%e7%89%b9%e6%80%a7animation-timeline-%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/blog.osvlabs.com\/?p=429","title":{"rendered":"\u5199\u6eda\u52a8\u52a8\u753b\u4e0d\u6b62\u65b9\u4fbf\u4e00\u70b9\u70b9\uff0cCSS\u672a\u6765\u7279\u6027animation-timeline \u4ecb\u7ecd"},"content":{"rendered":"<h1>\u524d\u8a00<\/h1>\n<p>\u4eca\u5929\u6765\u4ecb\u7ecd\u4e00\u4e2a\u5168\u65b0\u7684css \u7279\u6027\uff0c\u867d\u7136\u4ecd\u662f\u5b9e\u9a8c\u6027\u7279\u6027\uff0c\u517c\u5bb9\u6027\u5dee\u7684\u4e0d\u80fd\u63d0\uff0c\u4f46\u63d0\u524d\u4e86\u89e3\u4e5f\u975e\u5e38\u6709\u4ef7\u503c\uff0c\u56e0\u4e3a\u5b83\u5b9e\u5728\u628a\u6eda\u52a8\u52a8\u753b\u7b80\u5316\u592a\u591a\u4e86\u3002\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u4e5f\u53ef\u4ee5\u4f7f\u7528polyfill\uff1a <a href=\"https:\/\/github.com\/flackr\/scroll-timeline\">https:\/\/github.com\/flackr\/scroll-timeline<\/a><\/p>\n<h1>\u51c6\u5907<\/h1>\n<p>\u6709\u591a\u65b0\uff1f<br \/>\n\u770b\u770b\u8fd9\u4e00\u6e9c\u7ea2\u53c9\uff1a<br \/>\n<img src=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2022\/09\/animate-timeline-compatibility.png\" alt=\"\" \/><\/p>\n<p>\u5373\u4f7f\u4f60\u662f\u6700\u65b0\u7248\u7684Chrome\/Firefox \u4e5f\u5e76\u4e0d\u652f\u6301\u8fd9\u4e00\u7279\u6027\uff0c\u9700\u8981\u624b\u52a8\u5f00\u542f\u5b9e\u9a8c\u6027\u7279\u6027\uff1a<\/p>\n<p>Firefox \u8fdb\u5165 about:config, \u5c06 layout.css.scroll-linked-animations.enabled \u8bbe\u4e3atrue<br \/>\n<img src=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2022\/09\/firefox-scroll-linked-animations.png\" alt=\"\" \/><\/p>\n<p>Chrome \u8fdb\u5165chrome:\/\/flags<br \/>\n<img src=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2022\/09\/chrome-platform-feature.png\" alt=\"\" \/><\/p>\n<p>\u4e0d\u7136\u8fdedemo \u6548\u679c\u4e5f\u770b\u4e0d\u4e86 o(\u2565\ufe4f\u2565)o<\/p>\n<h1>\u6eda\u52a8\u52a8\u753b<\/h1>\n<p>\u7a0d\u5fae\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\u4f1a\u77e5\u9053\uff0c\u6eda\u52a8\u52a8\u753b\u7684\u539f\u7406\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u5373<br \/>\n\u76d1\u542c\u6eda\u52a8 -&gt; \u6839\u636e\u6eda\u52a8\u4f4d\u7f6e\u6539\u53d8\u5143\u7d20\u72b6\u6001<br \/>\n\u4f46\u8fd9\u4e1c\u897f\u8bf4\u8d77\u6765\u7b80\u5355\uff0c\u505a\u8d77\u6765\u590d\u6742\uff0c\u91c7\u7528\u547d\u4ee4\u5f0f\u7684\u63a7\u5236\u65b9\u6cd5\u6765\u505a\u7684\u8bdd\uff0c\u7b80\u5355\u4e00\u4e9b\u7684\u8fd8\u597d\u8bf4\uff0c\u9700\u8981\u64cd\u4f5c\u7684\u5143\u7d20\u4e00\u591a\u5c31\u4e71\u5957\u4e86\uff0c\u4e0d\u4f46\u6548\u679c\u4e0d\u597d\u5b9e\u73b0\uff0c\u51fa\u4e86\u95ee\u9898\u66f4\u4e0d\u597d\u4fee\u590d\u3002<br \/>\n\u6240\u4ee5\u5f00\u53d1\u8005\u901a\u5e38\u4f7f\u7528\u4e00\u4e9b\u5e93\u6765\u5b9e\u73b0\u6548\u679c\u3002<\/p>\n<h2>\u5e38\u7528\u5de5\u5177<\/h2>\n<p>\u7b80\u5355\u4e00\u70b9\u7684\u6709AOS: <a href=\"https:\/\/michalsnik.github.io\/aos\/\">https:\/\/michalsnik.github.io\/aos\/<\/a><br \/>\n\u9700\u8981\u590d\u6742\u6548\u679c\u7684\u6709 <a href=\"https:\/\/scrollrevealjs.org\/api\/reveal.html\">https:\/\/scrollrevealjs.org\/api\/reveal.html<\/a> GSAP \u7b49<br \/>\nGSAP \u9700\u8981\u4f7f\u7528\u5bf9\u5e94\u7684ScrollTrigger plugins\u3002<br \/>\n\u6bd4\u5982\u5927\u7586\u7684Mavic 3 \u4ecb\u7ecd\u5c31\u662f\u4f7f\u7528\u7684GSAP: <a href=\"https:\/\/www.dji.com\/cn\/mavic-3?site=brandsite&amp;from=homepage\">https:\/\/www.dji.com\/cn\/mavic-3?site=brandsite&#038;from=homepage<\/a><\/p>\n<p>\u4f46\u662f\uff0c\u5f53css \u539f\u751f\u652f\u6301\u540e\uff0c\u4e0d\u8003\u8651\u517c\u5bb9\u6027\u7684\u60c5\u51b5\u4e0b\uff0c\u5927\u90e8\u5206\u6211\u4eec\u90fd\u65e0\u9700\u518d\u5f15\u5165\u5e93\uff0c\u800c\u662f\u76f4\u63a5\u5b9a\u4e49\u5c5e\u6027\u5373\u53ef\u5feb\u901f\u51fa\u73b0\u6548\u679c\u3002<\/p>\n<h2>\u7528\u6cd5<\/h2>\n<p>\u4ee5MDN \u7684\u5b98\u65b9\u4f8b\u5b50\u4e3a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-html\">&lt;div id=&quot;container&quot;&gt;&lt;div id=&quot;square&quot;&gt;&lt;\/div&gt;&lt;\/div&gt;<\/code><\/pre>\n<pre><code class=\"language-css\">#container {\n    height: 300px;\n}\n\n#square {\n    background-color: deeppink;\n    width: 100px;\n    height: 100px;\n    margin-top: 100px;\n    animation-name: rotateAnimation;\n    animation-duration: 3s;\n    animation-direction: alternate;\n    animation-timeline: squareTimeline;\n}\n\n@scroll-timeline squareTimeline {\n    source:selector(&quot;#container&quot;);orientation:&quot;vertical&quot;;scroll-offsets:0px,300px;\n}\n\n@keyframe srotateAnimation {\n    from {\n        transform: rotate(0deg);\n    }\n\n    to {\n        transform: rotate(360deg);\n    }\n}<\/code><\/pre>\n<p>\u5176\u4e2d\u6700\u5173\u952e\u7684\u90e8\u5206\u4e3a\uff1a<\/p>\n<h3>animation-timeline<\/h3>\n<p>\u8be6\u7ec6\u8bf7\u53c2\u8003\uff1a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/animation-timeline\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/animation-timeline<\/a>\uff0c \u8fd9\u91cc\u6211\u4eec\u7ed9\u4e88\u5b83\u7684\u503c\u662f\u4e00\u4e2a scroll-timeline\u3002<\/p>\n<h3>@scroll-timeline<\/h3>\n<p>\u5b83\u5b9a\u4e49\u4e86\u6307\u5b9a\u5143\u7d20\u7684\u6eda\u52a8\u52a8\u753brule\uff0c\u8be6\u7ec6\u6587\u6863\u53c2\u8003MDN: <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/@scroll-timeline\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/@scroll-timeline<\/a>.<br \/>\n\u4e0d\u592a\u9700\u8981\u5173\u6ce8\u5177\u4f53\u5c5e\u6027\uff0c\u5f53\u524d\u7684\u8349\u6848\u4f3c\u4e4e\u5df2\u7ecf\u88ab\u5e9f\u5f03\u3002\u53ea\u9700\u8981\u58f0\u660escroll-timeline \u5373\u53ef\uff0c\u5b9e\u6d4b\u51e0\u9879\u5c5e\u6027\u5728\u6700\u65b0\u7248firefox \u4e2d\u51e0\u4e4e\u4e0d\u518d\u652f\u6301\u3002<br \/>\n\u5373\u8fd9\u6837\u4e5f\u53ef\u8fd0\u884c\uff1a<\/p>\n<pre><code class=\"language-css\"> animation-timeline: squareTimeline;\n\n@scroll-timeline squareTimeline {\n}<\/code><\/pre>\n<p><iframe height=\"300\" style=\"width: 100%;\" scrolling=\"no\" title=\"Untitled\" src=\"https:\/\/codepen.io\/hnsxxscyx\/embed\/LYmQpez?default-tab=html%2Cresult\" frameborder=\"no\" loading=\"lazy\" allowtransparency=\"true\" allowfullscreen=\"true\"><br \/>\n  See the Pen <a href=\"https:\/\/codepen.io\/hnsxxscyx\/pen\/LYmQpez\"><br \/>\n  Untitled<\/a> by \u4e0d\u5f97\u4e0d\u9519 (<a href=\"https:\/\/codepen.io\/hnsxxscyx\">@hnsxxscyx<\/a>)<br \/>\n  on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<br \/>\n<\/iframe><\/p>\n<h3>codepen \u5b9e\u4f8b\u6548\u679c<\/h3>\n<p><iframe height=\"300\" style=\"width: 100%;\" scrolling=\"no\" title=\"CSS Scroll-Timeline Split Screen Carousel\" src=\"https:\/\/codepen.io\/Chokcoco\/embed\/QWOrPdM?default-tab=html%2Cresult\" frameborder=\"no\" loading=\"lazy\" allowtransparency=\"true\" allowfullscreen=\"true\"><br \/>\n  See the Pen <a href=\"https:\/\/codepen.io\/Chokcoco\/pen\/QWOrPdM\"><br \/>\n  CSS Scroll-Timeline Split Screen Carousel<\/a> by Chokcoco (<a href=\"https:\/\/codepen.io\/Chokcoco\">@Chokcoco<\/a>)<br \/>\n  on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<br \/>\n<\/iframe><\/p>\n<h2>\u672b\u5c3e<\/h2>\n<p>\u8fd9\u6ce8\u5b9a\u662f\u4e00\u4e2a\u65e5\u5e38\u4e0d\u592a\u80fd\u4f7f\u7528\u5230\u7684\u65b0\u5c5e\u6027\uff0c\u751a\u81f3\u5728\u6d4f\u89c8\u5668\u6b63\u5f0f\u652f\u6301\u524d\u6807\u51c6\u4e5f\u4f1a\u6709\u4e9b\u5fae\u7684\u6539\u52a8\u3002<br \/>\n\u8fd9\u7bc7\u6587\u7ae0\u4e5f\u4ec5\u4ec5\u662f\u5bf9\u5176\u7684\u7b80\u5355\u4ecb\u7ecd\uff0c\u770b\u5b8c\u8fde\u5199\u4e2a\u5c0fdemo\u90fd\u8981\u53bb\u6253\u5f00\u6d4f\u89c8\u5668\u7684\u5b9e\u9a8c\u6027\u7279\u6027\u3002<br \/>\n\u4f46\u603b\u4f1a\u5230\u90a3\u4e48\u4e00\u4e2a\u65f6\u5019\uff0c\u53d1\u73b0\u517c\u5bb9\u6027\u5df2\u7ecf\u4e00\u773c\u7eff\uff0c\u6f47\u6d12\u7684\u52a0\u4e0a\u5c5e\u6027\u5b9e\u73b0\u6548\u679c\uff0c\u7136\u540e\u5fc3\u91cc\u6084\u6084\u611f\u6168\uff0c\u563f\uff0c\u8fd9\u641e\u7684\u8fd8\u771f\u65b9\u4fbf\u3002<br \/>\n\u5c31\u50cfposition: sticky \u4e00\u6837\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u4eca\u5929\u6765\u4ecb\u7ecd\u4e00\u4e2a\u5168\u65b0\u7684css \u7279\u6027\uff0c\u867d\u7136\u4ecd\u662f\u5b9e\u9a8c\u6027\u7279\u6027\uff0c\u517c\u5bb9\u6027\u5dee\u7684\u4e0d\u80fd\u63d0\uff0c\u4f46\u63d0\u524d\u4e86\u89e3\u4e5f\u975e\u5e38\u6709\u4ef7\u503c\uff0c\u56e0\u4e3a\u5b83\u5b9e\u5728\u628a\u6eda\u52a8\u52a8\u753b\u7b80\u5316\u592a\u591a\u4e86\u3002\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u4e5f\u53ef\u4ee5\u4f7f\u7528polyfill\uff1a https:\/\/gith\u2026<\/p>\n","protected":false},"author":2,"featured_media":434,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"_links":{"self":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts\/429"}],"collection":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=429"}],"version-history":[{"count":3,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts\/429\/revisions"}],"predecessor-version":[{"id":436,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts\/429\/revisions\/436"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/media\/434"}],"wp:attachment":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}