overview.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>SVG - Overview</title>
  7. <link rel="stylesheet" href="../demo.css">
  8. <style>
  9. .grid {
  10. display: grid;
  11. grid-template-columns: repeat(3, minmax(0, 1fr));
  12. gap: 14px;
  13. }
  14. .tile {
  15. background: rgba(255,255,255,0.02);
  16. border: 1px solid #242424;
  17. border-radius: 12px;
  18. padding: 14px;
  19. min-height: 120px;
  20. overflow: hidden;
  21. position: relative;
  22. }
  23. .tile h3 {
  24. margin: 0 0 8px;
  25. font-size: 13px;
  26. color: #fff;
  27. font-weight: 800;
  28. }
  29. .tile p {
  30. margin: 0;
  31. font-size: 12px;
  32. color: #a8a8a8;
  33. line-height: 1.6;
  34. }
  35. .badge {
  36. position: absolute;
  37. right: 12px;
  38. top: 12px;
  39. font-size: 10px;
  40. font-weight: 900;
  41. letter-spacing: 0.8px;
  42. color: #6f6f6f;
  43. text-transform: uppercase;
  44. background: rgba(255,255,255,0.02);
  45. border: 1px solid #2a2a2a;
  46. padding: 4px 8px;
  47. border-radius: 999px;
  48. }
  49. .tile svg { width: 100%; height: 64px; margin-top: 10px; }
  50. .stroke { fill: none; stroke: rgba(255,255,255,0.2); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
  51. .stroke.orange { stroke: #ff9f43; opacity: 0.9; }
  52. .stroke.red { stroke: #ff4b4b; opacity: 0.9; }
  53. .dot { fill: #ff9f43; opacity: 0.95; }
  54. </style>
  55. </head>
  56. <body>
  57. <div class="container">
  58. <div class="page-top">
  59. <div class="crumb">ANIMATION › SVG</div>
  60. <div class="since">SINCE 1.0.0</div>
  61. </div>
  62. <h1>SVG</h1>
  63. <p class="description">
  64. SVG 动画最容易“看起来像魔法”。这组示例会用 <code class="inline">xjs</code> 展示几种常见玩法:<br>
  65. <strong>路径描边</strong>、<strong>沿路径运动</strong>、<strong>属性动画</strong>、以及 <strong>transform 动画</strong>。
  66. </p>
  67. <h2>你会看到什么?</h2>
  68. <div class="grid">
  69. <div class="tile">
  70. <div class="badge">draw</div>
  71. <h3>路径描边(draw)</h3>
  72. <p>把路径变成“正在被画出来”的效果。适合 logo / loading / 强调线条。</p>
  73. <svg viewBox="0 0 120 60" aria-hidden="true">
  74. <path class="stroke" d="M10,42 C25,10 48,10 60,30 C72,50 92,50 110,18" />
  75. <path class="stroke orange" d="M10,42 C25,10 48,10 60,30 C72,50 92,50 110,18" />
  76. </svg>
  77. </div>
  78. <div class="tile">
  79. <div class="badge">motion</div>
  80. <h3>沿路径运动(Motion Path)</h3>
  81. <p>一个点沿着 path 跑,像小飞机/小精灵巡航。用 update 回调把进度映射到路径长度。</p>
  82. <svg viewBox="0 0 120 60" aria-hidden="true">
  83. <path class="stroke" d="M8,44 C26,8 56,6 74,30 C90,52 102,50 112,16" />
  84. <circle class="dot" cx="24" cy="32" r="4" />
  85. </svg>
  86. </div>
  87. <div class="tile">
  88. <div class="badge">attr</div>
  89. <h3>SVG 属性动画(cx / r / …)</h3>
  90. <p>不是所有 SVG 属性都走 WAAPI;有些会走 JS fallback,但写法一样简洁。</p>
  91. <svg viewBox="0 0 120 60" aria-hidden="true">
  92. <circle class="stroke red" cx="38" cy="30" r="10" />
  93. <circle class="stroke orange" cx="78" cy="30" r="16" />
  94. </svg>
  95. </div>
  96. </div>
  97. <div class="box-container" style="margin-top: 18px;">
  98. <div class="box-header">
  99. <div class="box-title">一句话总结</div>
  100. </div>
  101. <div class="feature-desc">
  102. <strong>核心心法:</strong>
  103. <br>- SVG 动画的“视觉冲击力”来自<strong>路径</strong>与<strong>形状变化</strong>。
  104. <br>- 你可以把“进度(0..1)”当作万能遥控器:它能驱动位置、旋转、描边、透明度……几乎一切。
  105. </div>
  106. <div class="action-bar">
  107. <button class="play-btn" onclick="goNext()">开始看第一个示例 →</button>
  108. </div>
  109. </div>
  110. <div class="doc-nav" aria-label="Previous and next navigation">
  111. <a href="#" onclick="goPrev(); return false;">
  112. <span>
  113. <span class="nav-label">Previous</span><br>
  114. <span id="prev-title" class="nav-title">—</span>
  115. </span>
  116. <span aria-hidden="true">←</span>
  117. </a>
  118. <div id="nav-center" class="nav-center">SVG</div>
  119. <a href="#" onclick="goNext(); return false;">
  120. <span>
  121. <span class="nav-label">Next</span><br>
  122. <span id="next-title" class="nav-title">—</span>
  123. </span>
  124. <span aria-hidden="true">→</span>
  125. </a>
  126. </div>
  127. </div>
  128. <div id="toast" class="toast" role="status" aria-live="polite"></div>
  129. <script src="../page_utils.js"></script>
  130. <script>
  131. const CURRENT = 'svg/overview.html';
  132. function goPrev() { window.parent?.docNavigatePrev?.(CURRENT); }
  133. function goNext() { window.parent?.docNavigateNext?.(CURRENT); }
  134. DocPage.syncMiddleActive(CURRENT);
  135. DocPage.syncPrevNext(CURRENT);
  136. </script>
  137. </body>
  138. </html>