test_icons_svg_animation.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Layer SVG Icon Animation - Animal.js</title>
  7. <link rel="stylesheet" href="../demo.css">
  8. <style>
  9. .controls {
  10. display: flex;
  11. flex-wrap: wrap;
  12. gap: 12px 16px;
  13. align-items: center;
  14. font-size: 13px;
  15. color: #b7b7b7;
  16. }
  17. .controls label {
  18. display: inline-flex;
  19. gap: 8px;
  20. align-items: center;
  21. cursor: pointer;
  22. user-select: none;
  23. }
  24. .controls input { accent-color: var(--highlight-color); }
  25. .row {
  26. display: flex;
  27. flex-wrap: wrap;
  28. gap: 10px;
  29. align-items: center;
  30. }
  31. .btn {
  32. appearance: none;
  33. border: 1px solid rgba(255,255,255,0.12);
  34. background: rgba(255,255,255,0.04);
  35. color: #fff;
  36. border-radius: 999px;
  37. padding: 10px 14px;
  38. font-weight: 650;
  39. cursor: pointer;
  40. transition: border-color 0.15s ease, background 0.15s ease;
  41. }
  42. .btn:hover { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.06); }
  43. .btn.success { border-color: rgba(165,220,134,0.55); background: rgba(165,220,134,0.12); }
  44. .btn.error { border-color: rgba(242,116,116,0.55); background: rgba(242,116,116,0.12); }
  45. .btn.warning { border-color: rgba(248,187,134,0.55); background: rgba(248,187,134,0.12); }
  46. .btn.info { border-color: rgba(63,195,238,0.55); background: rgba(63,195,238,0.12); }
  47. .demo-visual { padding: 22px 24px; }
  48. .hint { font-size: 12px; color: #8c8c8c; line-height: 1.5; margin-top: 10px; }
  49. </style>
  50. </head>
  51. <body>
  52. <div class="container">
  53. <div class="page-top">
  54. <div class="crumb">UI › LAYER</div>
  55. <div class="since">ICON ANIMATION</div>
  56. </div>
  57. <h1>SVG Icon animation</h1>
  58. <p class="description">
  59. Uses <code class="inline">xjs.draw()</code> to animate the ring + mark strokes, and a spring entrance to mimic SweetAlert-like feedback.
  60. </p>
  61. <div class="box-container">
  62. <div class="box-header">
  63. <div class="box-title">Controls</div>
  64. <div class="tabs">
  65. <div class="tab active" onclick="switchTab('js')">JavaScript</div>
  66. <div class="tab" onclick="switchTab('html')">HTML</div>
  67. <div class="tab" onclick="switchTab('css')">CSS</div>
  68. </div>
  69. </div>
  70. <pre id="js-code" class="code-view active">xjs.layer({
  71. title: 'Success',
  72. text: 'SVG draw + spring',
  73. icon: 'success',
  74. iconAnimation: true,
  75. popupAnimation: true
  76. });</pre>
  77. <pre id="html-code" class="html-view">&lt;label&gt;&lt;input type="checkbox" checked&gt; iconAnimation&lt;/label&gt;
  78. &lt;label&gt;&lt;input type="checkbox" checked&gt; popupAnimation&lt;/label&gt;</pre>
  79. <pre id="css-code" class="css-view">/* Icon styling lives inside layer.js */</pre>
  80. <div class="feature-desc">
  81. <strong>功能说明:</strong>本页专门验证 Layer 的 icon 动画:描边(draw)+ 弹性缩放(spring)。你可以关闭其中任意一项来对比体验。
  82. </div>
  83. <div class="demo-visual">
  84. <div class="controls" style="margin-bottom: 14px;">
  85. <label><input id="optIcon" type="checkbox" checked> iconAnimation</label>
  86. <label><input id="optPopup" type="checkbox" checked> popupAnimation</label>
  87. <label><input id="optEsc" type="checkbox" checked> closeOnEsc</label>
  88. </div>
  89. <div class="row">
  90. <button class="btn success" onclick="open('success')">Success</button>
  91. <button class="btn error" onclick="open('error')">Error</button>
  92. <button class="btn warning" onclick="open('warning')">Warning</button>
  93. <button class="btn info" onclick="open('info')">Info</button>
  94. </div>
  95. <div class="hint">
  96. Tip: open “Error” to see the two stroke segments staggered.
  97. </div>
  98. </div>
  99. </div>
  100. <div class="doc-nav" aria-label="Previous and next navigation">
  101. <a href="#" id="prevLink" onclick="goPrev(); return false;">
  102. <span><span class="nav-label">Previous</span><br><span class="nav-title" id="prevTitle">—</span></span>
  103. <span aria-hidden="true">←</span>
  104. </a>
  105. <div class="nav-center" id="navCenter">Layer</div>
  106. <a href="#" id="nextLink" onclick="goNext(); return false;">
  107. <span><span class="nav-label">Next</span><br><span class="nav-title" id="nextTitle">—</span></span>
  108. <span aria-hidden="true">→</span>
  109. </a>
  110. </div>
  111. </div>
  112. <script src="../highlight_css.js"></script>
  113. <script src="../../xjs.js"></script>
  114. <script>
  115. const CURRENT = 'layer/test_icons_svg_animation.html';
  116. function switchTab(tab) {
  117. document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
  118. document.querySelectorAll('.code-view, .html-view, .css-view').forEach(v => v.classList.remove('active'));
  119. if (tab === 'js') {
  120. document.querySelector('.tabs .tab:nth-child(1)')?.classList.add('active');
  121. document.getElementById('js-code')?.classList.add('active');
  122. } else if (tab === 'html') {
  123. document.querySelector('.tabs .tab:nth-child(2)')?.classList.add('active');
  124. document.getElementById('html-code')?.classList.add('active');
  125. } else {
  126. document.querySelector('.tabs .tab:nth-child(3)')?.classList.add('active');
  127. document.getElementById('css-code')?.classList.add('active');
  128. }
  129. }
  130. function open(type) {
  131. const iconAnimation = !!document.getElementById('optIcon')?.checked;
  132. const popupAnimation = !!document.getElementById('optPopup')?.checked;
  133. const closeOnEsc = !!document.getElementById('optEsc')?.checked;
  134. xjs.layer({
  135. title: type[0].toUpperCase() + type.slice(1),
  136. text: 'SVG draw + spring entrance',
  137. icon: type,
  138. iconAnimation,
  139. popupAnimation,
  140. closeOnEsc
  141. });
  142. }
  143. function goPrev() { window.parent?.docNavigatePrev?.(CURRENT); }
  144. function goNext() { window.parent?.docNavigateNext?.(CURRENT); }
  145. function syncNavLabels() {
  146. const api = window.parent?.docGetPrevNext;
  147. if (typeof api !== 'function') return;
  148. const { prev, next, current } = api(CURRENT) || {};
  149. const prevLink = document.getElementById('prevLink');
  150. const nextLink = document.getElementById('nextLink');
  151. if (prev) document.getElementById('prevTitle').textContent = prev.title || prev.url;
  152. else { prevLink.style.visibility = 'hidden'; }
  153. if (next) document.getElementById('nextTitle').textContent = next.title || next.url;
  154. else { nextLink.style.visibility = 'hidden'; }
  155. document.getElementById('navCenter').textContent = (current && current.group) ? current.group : 'Layer';
  156. }
  157. try { window.parent?.setMiddleActive?.(CURRENT); } catch {}
  158. syncNavLabels();
  159. </script>
  160. </body>
  161. </html>