test_custom_animation_container_steps.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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 容器定义混合类型动画</title>
  7. <link rel="stylesheet" href="../demo.css">
  8. <link rel="stylesheet" href="../../xjs.css">
  9. <style>
  10. /* Keep Layer above the doc UI */
  11. .layer-overlay { z-index: 99999; }
  12. </style>
  13. <style>
  14. .controls {
  15. display: flex;
  16. flex-wrap: wrap;
  17. gap: 10px 12px;
  18. align-items: center;
  19. font-size: 13px;
  20. color: #b7b7b7;
  21. }
  22. .row {
  23. display: flex;
  24. flex-wrap: wrap;
  25. gap: 10px;
  26. align-items: center;
  27. }
  28. .btn {
  29. appearance: none;
  30. border: 1px solid rgba(255,255,255,0.12);
  31. background: rgba(255,255,255,0.04);
  32. color: #fff;
  33. border-radius: 999px;
  34. padding: 10px 14px;
  35. font-weight: 650;
  36. cursor: pointer;
  37. transition: border-color 0.15s ease, background 0.15s ease;
  38. }
  39. .btn:hover { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.06); }
  40. .demo-visual { padding: 22px 24px; }
  41. .hint { font-size: 12px; color: #8c8c8c; line-height: 1.5; margin-top: 10px; }
  42. .hidden-dom { display: none; }
  43. .step-card {
  44. display: grid;
  45. gap: 10px;
  46. text-align: left;
  47. }
  48. .step-title {
  49. font-weight: 650;
  50. color: #1d1d1d;
  51. font-size: 14px;
  52. }
  53. .step-desc {
  54. color: #4d4d4d;
  55. font-size: 13px;
  56. line-height: 1.5;
  57. }
  58. .field label {
  59. display: block;
  60. font-size: 12px;
  61. color: #666;
  62. margin-bottom: 6px;
  63. }
  64. .field input, .field select {
  65. width: 100%;
  66. box-sizing: border-box;
  67. padding: 10px 12px;
  68. border-radius: 10px;
  69. border: 1px solid rgba(0,0,0,0.12);
  70. outline: none;
  71. background: #fff;
  72. color: #111;
  73. font-size: 14px;
  74. }
  75. </style>
  76. </head>
  77. <body>
  78. <div class="container">
  79. <div class="page-top">
  80. <div class="crumb">UI › LAYER</div>
  81. <div class="since">CUSTOM ANIMATION</div>
  82. </div>
  83. <h1>容器定义混合类型动画</h1>
  84. <p class="description">
  85. 使用 <code class="inline">step: '#container'</code> + <code class="inline">stepItem: '.item'</code>,
  86. 通过 DOM 属性定义每一步的 <code class="inline">background / icon / width / height / iwidth / iheight / theme</code>,
  87. 并展示 SVG 动画背景与 SVG 图标混合使用的效果。
  88. </p>
  89. <div class="box-container">
  90. <div class="demo-visual">
  91. <div class="controls" style="margin-bottom: 14px;">
  92. <span>点击按钮触发容器式 Steps</span>
  93. </div>
  94. <div class="row">
  95. <button class="btn" type="button" onclick="openContainerSteps()">Open container steps</button>
  96. </div>
  97. <div class="hint">
  98. Tip: 每个 stepItem 通过 <code class="inline">data-step-*</code> 控制动画与样式。
  99. </div>
  100. </div>
  101. <div class="box-header">
  102. <div class="box-title">Controls</div>
  103. <div class="tabs">
  104. <div class="tab active" onclick="switchTab('js')">JavaScript</div>
  105. <div class="tab" onclick="switchTab('html')">HTML</div>
  106. <div class="tab" onclick="switchTab('css')">CSS</div>
  107. </div>
  108. </div>
  109. <pre id="js-code" class="code-view active">function openContainerSteps() {
  110. if (typeof window.$ !== 'function') return;
  111. Layer.run({
  112. step: '#mix_steps',
  113. stepItem: '.mix-step',
  114. title: 'Container steps (mixed animations)',
  115. showCancelButton: true
  116. }).then((res) =&gt; {
  117. if (res.isConfirmed) {
  118. Layer.run({
  119. title: 'Collected data',
  120. icon: 'success',
  121. popupAnimation: false,
  122. replace: true,
  123. html: '&lt;pre&gt;' + JSON.stringify(res.data, null, 2) + '&lt;/pre&gt;'
  124. });
  125. }
  126. });
  127. }</pre>
  128. <pre id="html-code" class="html-view">&lt;button class="btn" type="button" onclick="openContainerSteps()"&gt;Open container steps&lt;/button&gt;
  129. &lt;div id="mix_steps" class="hidden-dom"&gt;
  130. &lt;div class="mix-step"
  131. data-step-title="Step 1: Banner icon"
  132. data-step-icon="svg:banner"
  133. data-step-iwidth="10em"
  134. data-step-iheight="6em"
  135. data-step-width="520"
  136. data-step-height="260"
  137. data-step-theme="light"&gt;
  138. &lt;div class="step-card"&gt;
  139. &lt;div class="step-title"&gt;Welcome&lt;/div&gt;
  140. &lt;div class="step-desc"&gt;This step uses a Lottie SVG icon with custom icon box size.&lt;/div&gt;
  141. &lt;div class="field"&gt;
  142. &lt;label&gt;Your name&lt;/label&gt;
  143. &lt;input name="name" placeholder="Input will be collected"&gt;
  144. &lt;/div&gt;
  145. &lt;/div&gt;
  146. &lt;/div&gt;
  147. &lt;div class="mix-step"
  148. data-step-title="Step 2: SVG background"
  149. data-step-background="svg(BallSorting.json)"
  150. data-step-width="560"
  151. data-step-height="280"
  152. data-step-theme="light"&gt;
  153. &lt;div class="step-card"&gt;
  154. &lt;div class="step-title"&gt;Pick a plan&lt;/div&gt;
  155. &lt;div class="step-desc"&gt;This step uses a Lottie background animation.&lt;/div&gt;
  156. &lt;div class="field"&gt;
  157. &lt;label&gt;Plan&lt;/label&gt;
  158. &lt;select name="plan"&gt;
  159. &lt;option value="free"&gt;Free&lt;/option&gt;
  160. &lt;option value="pro"&gt;Pro&lt;/option&gt;
  161. &lt;option value="team"&gt;Team&lt;/option&gt;
  162. &lt;/select&gt;
  163. &lt;/div&gt;
  164. &lt;/div&gt;
  165. &lt;/div&gt;
  166. &lt;div class="mix-step"
  167. data-step-title="Step 3: Mixed icon + css background"
  168. data-step-icon="svg:BallSorting"
  169. data-step-iwidth="8em"
  170. data-step-iheight="8em"
  171. data-step-background="css(background: linear-gradient(135deg, rgba(32, 32, 48, 0.9), rgba(10, 10, 12, 0.92));)"
  172. data-step-width="520"
  173. data-step-height="260"
  174. data-step-theme="light"&gt;
  175. &lt;div class="step-card"&gt;
  176. &lt;div class="step-title"&gt;Confirm&lt;/div&gt;
  177. &lt;div class="step-desc"&gt;Background and icon are both customized here.&lt;/div&gt;
  178. &lt;div class="field"&gt;
  179. &lt;label&gt;Note&lt;/label&gt;
  180. &lt;input name="note" placeholder="Optional note"&gt;
  181. &lt;/div&gt;
  182. &lt;/div&gt;
  183. &lt;/div&gt;
  184. &lt;/div&gt;</pre>
  185. <pre id="css-code" class="css-view">.hidden-dom { display: none; }
  186. .step-card { display: grid; gap: 10px; text-align: left; }
  187. .step-title { font-weight: 650; color: #1d1d1d; font-size: 14px; }
  188. .step-desc { color: #4d4d4d; font-size: 13px; line-height: 1.5; }</pre>
  189. <div class="feature-desc">
  190. <strong>功能说明:</strong>容器式 steps 会根据 <code class="inline">data-step-*</code> 动态设置每一步的背景与图标,
  191. 并通过内置表单收集机制把 <code class="inline">input/select</code> 汇总到 <code class="inline">res.data</code>。
  192. </div>
  193. </div>
  194. <!-- Hidden DOM container -->
  195. <div id="mix_steps" class="hidden-dom">
  196. <div class="mix-step"
  197. data-step-title="Step 1: Banner icon"
  198. data-step-icon="svg:banner"
  199. data-step-iwidth="10em"
  200. data-step-iheight="6em"
  201. data-step-width="520"
  202. data-step-height="260"
  203. data-step-theme="light">
  204. <div class="step-card">
  205. <div class="step-title">Welcome</div>
  206. <div class="step-desc">This step uses a Lottie SVG icon with custom icon box size.</div>
  207. <div class="field">
  208. <label>Your name</label>
  209. <input name="name" placeholder="Input will be collected">
  210. </div>
  211. </div>
  212. </div>
  213. <div class="mix-step"
  214. data-step-title="Step 2: SVG background"
  215. data-step-background="svg(BallSorting.json)"
  216. data-step-width="560"
  217. data-step-height="280"
  218. data-step-theme="light">
  219. <div class="step-card">
  220. <div class="step-title">Pick a plan</div>
  221. <div class="step-desc">This step uses a Lottie background animation.</div>
  222. <div class="field">
  223. <label>Plan</label>
  224. <select name="plan">
  225. <option value="free">Free</option>
  226. <option value="pro">Pro</option>
  227. <option value="team">Team</option>
  228. </select>
  229. </div>
  230. </div>
  231. </div>
  232. <div class="mix-step"
  233. data-step-title="Step 3: Mixed icon + css background"
  234. data-step-icon="svg:BallSorting"
  235. data-step-iwidth="8em"
  236. data-step-iheight="8em"
  237. data-step-background="css(background: linear-gradient(135deg, rgba(32, 32, 48, 0.9), rgba(10, 10, 12, 0.92));)"
  238. data-step-width="520"
  239. data-step-height="260"
  240. data-step-theme="light">
  241. <div class="step-card">
  242. <div class="step-title">Confirm</div>
  243. <div class="step-desc">Background and icon are both customized here.</div>
  244. <div class="field">
  245. <label>Note</label>
  246. <input name="note" placeholder="Optional note">
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. <div class="doc-nav" aria-label="Previous and next navigation">
  252. <a href="#" id="prevLink" onclick="goPrev(); return false;">
  253. <span><span class="nav-label">Previous</span><br><span class="nav-title" id="prevTitle">—</span></span>
  254. <span aria-hidden="true">←</span>
  255. </a>
  256. <div class="nav-center" id="navCenter">Layer</div>
  257. <a href="#" id="nextLink" onclick="goNext(); return false;">
  258. <span><span class="nav-label">Next</span><br><span class="nav-title" id="nextTitle">—</span></span>
  259. <span aria-hidden="true">→</span>
  260. </a>
  261. </div>
  262. </div>
  263. <script src="../highlight_css.js"></script>
  264. <!-- Dev/test: load source files directly with cache-bust (avoid stale iframe cache) -->
  265. <script>
  266. (function () {
  267. var b = Date.now();
  268. document.write('<script src="../../animal.js?_=' + b + '"><\/script>');
  269. document.write('<script src="../../layer.js?_=' + b + '"><\/script>');
  270. document.write('<script>try{if(window.animal&&!window.xjs)window.xjs=window.animal;}catch(e){}<\/script>');
  271. })();
  272. </script>
  273. <script>
  274. const CURRENT = 'layer/test_custom_animation_container_steps.html';
  275. function switchTab(tab) {
  276. document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
  277. document.querySelectorAll('.code-view, .html-view, .css-view').forEach(v => v.classList.remove('active'));
  278. if (tab === 'js') {
  279. document.querySelector('.tabs .tab:nth-child(1)')?.classList.add('active');
  280. document.getElementById('js-code')?.classList.add('active');
  281. } else if (tab === 'html') {
  282. document.querySelector('.tabs .tab:nth-child(2)')?.classList.add('active');
  283. document.getElementById('html-code')?.classList.add('active');
  284. } else {
  285. document.querySelector('.tabs .tab:nth-child(3)')?.classList.add('active');
  286. document.getElementById('css-code')?.classList.add('active');
  287. }
  288. }
  289. function openContainerSteps() {
  290. if (typeof window.$ !== 'function') return;
  291. Layer.run({
  292. step: '#mix_steps',
  293. stepItem: '.mix-step',
  294. title: 'Container steps (mixed animations)',
  295. showCancelButton: true
  296. }).then((res) => {
  297. if (res.isConfirmed) {
  298. Layer.run({
  299. title: 'Collected data',
  300. icon: 'success',
  301. popupAnimation: false,
  302. replace: true,
  303. html: '<pre>' + JSON.stringify(res.data, null, 2) + '</pre>'
  304. });
  305. }
  306. });
  307. }
  308. function goPrev() { window.parent?.docNavigatePrev?.(CURRENT); }
  309. function goNext() { window.parent?.docNavigateNext?.(CURRENT); }
  310. function syncNavLabels() {
  311. const api = window.parent?.docGetPrevNext;
  312. if (typeof api !== 'function') return;
  313. const { prev, next, current } = api(CURRENT) || {};
  314. const prevLink = document.getElementById('prevLink');
  315. const nextLink = document.getElementById('nextLink');
  316. if (prev) document.getElementById('prevTitle').textContent = prev.title || prev.url;
  317. else { prevLink.style.visibility = 'hidden'; }
  318. if (next) document.getElementById('nextTitle').textContent = next.title || next.url;
  319. else { nextLink.style.visibility = 'hidden'; }
  320. document.getElementById('navCenter').textContent = (current && current.group) ? current.group : 'Layer';
  321. }
  322. try { window.parent?.setMiddleActive?.(CURRENT); } catch {}
  323. syncNavLabels();
  324. </script>
  325. </body>
  326. </html>