dsh-design-studio 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +2 -1
- package/README.md +2 -1
- package/THIRD_PARTY_NOTICES.md +319 -0
- package/assets/motion/ai-capsule.html +4 -2
- package/assets/motion/ai-glow-input.html +4 -2
- package/assets/motion/app-fab.html +130 -0
- package/assets/motion/app-gallery.html +125 -0
- package/assets/motion/app-index.html +138 -0
- package/assets/motion/app-largetitle.html +138 -0
- package/assets/motion/app-onboard.html +141 -0
- package/assets/motion/app-player.html +152 -0
- package/assets/motion/app-popover.html +133 -0
- package/assets/motion/app-rings.html +143 -0
- package/assets/motion/app-searchhist.html +131 -0
- package/assets/motion/app-tabbar.html +148 -0
- package/assets/motion/app-tabs.html +150 -0
- package/assets/motion/app-video.html +136 -0
- package/assets/motion/balance-odometer.html +4 -2
- package/assets/motion/bottom-sheet.html +4 -2
- package/assets/motion/brightness-pill.html +4 -2
- package/assets/motion/chart-area.html +111 -0
- package/assets/motion/chart-bar.html +100 -0
- package/assets/motion/chart-donut.html +145 -0
- package/assets/motion/chart-funnel.html +120 -0
- package/assets/motion/chart-gantt.html +140 -0
- package/assets/motion/chart-gauge.html +126 -0
- package/assets/motion/chart-heat.html +121 -0
- package/assets/motion/chart-kpi.html +110 -0
- package/assets/motion/chart-line.html +154 -0
- package/assets/motion/chart-radar.html +153 -0
- package/assets/motion/chart-rank.html +112 -0
- package/assets/motion/chart-stack.html +107 -0
- package/assets/motion/comet-ring.html +4 -2
- package/assets/motion/copy-morph.html +4 -2
- package/assets/motion/cube-grid.html +4 -2
- package/assets/motion/day-night.html +4 -2
- package/assets/motion/dial-knob.html +4 -2
- package/assets/motion/dock-magnify.html +4 -2
- package/assets/motion/download-ring.html +4 -2
- package/assets/motion/expand-card.html +4 -2
- package/assets/motion/flip-card.html +4 -2
- package/assets/motion/hold-pay.html +4 -2
- package/assets/motion/holo-card.html +4 -2
- package/assets/motion/keycap.html +4 -2
- package/assets/motion/like-jelly.html +4 -2
- package/assets/motion/liquid-progress.html +4 -2
- package/assets/motion/liquid-segment.html +4 -2
- package/assets/motion/live-capsule.html +4 -2
- package/assets/motion/m-actionsheet.html +84 -0
- package/assets/motion/m-address.html +113 -0
- package/assets/motion/m-buybar.html +122 -0
- package/assets/motion/m-calendar.html +135 -0
- package/assets/motion/m-capsule-nav.html +97 -0
- package/assets/motion/m-cart.html +162 -0
- package/assets/motion/m-category.html +154 -0
- package/assets/motion/m-chat.html +125 -0
- package/assets/motion/m-coupon.html +84 -0
- package/assets/motion/m-dialog.html +102 -0
- package/assets/motion/m-empty.html +121 -0
- package/assets/motion/m-filter.html +171 -0
- package/assets/motion/m-goods.html +151 -0
- package/assets/motion/m-grid.html +98 -0
- package/assets/motion/m-login.html +127 -0
- package/assets/motion/m-msglist.html +88 -0
- package/assets/motion/m-order.html +111 -0
- package/assets/motion/m-profile.html +110 -0
- package/assets/motion/m-pull.html +199 -0
- package/assets/motion/m-settings.html +81 -0
- package/assets/motion/m-sku.html +114 -0
- package/assets/motion/m-swiper.html +163 -0
- package/assets/motion/m-timeline.html +109 -0
- package/assets/motion/m-wheel.html +182 -0
- package/assets/motion/marker-highlight.html +4 -2
- package/assets/motion/marquee-logos.html +4 -2
- package/assets/motion/mp-cartbar.html +158 -0
- package/assets/motion/mp-checkin.html +121 -0
- package/assets/motion/mp-form.html +128 -0
- package/assets/motion/mp-group.html +148 -0
- package/assets/motion/mp-invite.html +119 -0
- package/assets/motion/mp-points.html +143 -0
- package/assets/motion/mp-queue.html +136 -0
- package/assets/motion/mp-rate.html +166 -0
- package/assets/motion/mp-seckill.html +140 -0
- package/assets/motion/mp-store.html +137 -0
- package/assets/motion/mp-vip.html +126 -0
- package/assets/motion/mp-wizard.html +174 -0
- package/assets/motion/otp-code.html +7 -4
- package/assets/motion/password-eye.html +4 -2
- package/assets/motion/ruler-slider.html +4 -2
- package/assets/motion/search-expand.html +4 -2
- package/assets/motion/send-fly.html +4 -2
- package/assets/motion/skeleton-shine.html +4 -2
- package/assets/motion/star-rate.html +4 -2
- package/assets/motion/success-check.html +4 -2
- package/assets/motion/suggest-chips.html +4 -2
- package/assets/motion/swipe-row.html +4 -2
- package/assets/motion/tabbar-bounce.html +4 -2
- package/assets/motion/tactile-controls.html +4 -2
- package/assets/motion/text-scramble.html +4 -2
- package/assets/motion/toast-stack.html +4 -2
- package/assets/motion/token-stream.html +4 -2
- package/assets/motion/um-bell.html +106 -0
- package/assets/motion/um-chips.html +132 -0
- package/assets/motion/um-coin.html +119 -0
- package/assets/motion/um-hue.html +128 -0
- package/assets/motion/um-ink-switch.html +129 -0
- package/assets/motion/um-leaf-tabs.html +138 -0
- package/assets/motion/um-plan.html +110 -0
- package/assets/motion/um-radial.html +104 -0
- package/assets/motion/um-stroke-check.html +86 -0
- package/assets/motion/um-swipe-confirm.html +182 -0
- package/assets/motion/um-tide.html +180 -0
- package/assets/motion/voice-orb.html +4 -2
- package/assets/motion/web-404.html +95 -0
- package/assets/motion/web-cmdk.html +167 -0
- package/assets/motion/web-dropdown.html +94 -0
- package/assets/motion/web-faq.html +84 -0
- package/assets/motion/web-footer.html +109 -0
- package/assets/motion/web-hero.html +98 -0
- package/assets/motion/web-navbar.html +149 -0
- package/assets/motion/web-newsletter.html +124 -0
- package/assets/motion/web-pagination.html +132 -0
- package/assets/motion/web-pricing.html +110 -0
- package/assets/motion/web-testimonial.html +129 -0
- package/assets/motion/web-upload.html +160 -0
- package/lib/client.js +72 -14
- package/lib/index.js +6 -2
- package/lib/motion.js +11 -2
- package/package.json +1 -1
|
@@ -0,0 +1,125 @@
|
|
|
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">
|
|
6
|
+
<title>九宫格看图</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"app-gallery","zh":"九宫格看图","en":"Photo Grid","cat":"mobile","desc":"3×3 九宫格看图,点任意格子放大预览,支持左右切换与关闭","desc_en":"3x3 photo grid that expands any tapped tile into an inline lightbox with prev/next switching","needs":"js","play":"press","hint":"点图看大图","hint_en":"Tap a photo","source":null,"prompt":"移动端九宫格看图:宽 248px 高 172px 圆角 18px 的 --color-surface 卡片,顶部显示标题与「9 张」计数,下方 3×3 九宫格缩略图(9 张风景画面全由纯 CSS 多层渐变绘制)。点击任意缩略图后,组件内弹出暗底大图预览层(scale 从 0.86 弹到 1,260ms),底部显示当前图名、页码与左右切换箭头,右上角有关闭按钮;切换图片带轻柔位移动画,关闭后回到九宫格。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary。","prompt_en":"Mobile 3x3 photo grid: 248x172 --color-surface card with 18px radius, header count, and 9 CSS-gradient landscape thumbnails. Tapping any tile expands an inline dark lightbox (scale 0.86 to 1 over 260ms) displaying the enlarged scene, title, index counter, prev/next buttons, and a close control. Switching photos slides smoothly; closing returns to the grid. Reads --color-surface / --color-text / --color-muted / --color-line / --color-primary."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 九宫格看图:纯 CSS 渐变风景缩略图与内联放大预览层。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary */
|
|
18
|
+
.c-app-gallery{position:relative;width:248px;height:172px;border-radius:18px;overflow:hidden;padding:8px 10px 10px;box-sizing:border-box;display:flex;flex-direction:column;gap:6px;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.3);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
19
|
+
.c-app-gallery .gl-hd{display:flex;align-items:center;justify-content:space-between;height:18px}
|
|
20
|
+
.c-app-gallery .gl-hd b{font-size:12px;font-weight:700}
|
|
21
|
+
.c-app-gallery .gl-hd span{font-size:10.5px;color:var(--color-muted,#76756f);font-variant-numeric:tabular-nums}
|
|
22
|
+
.c-app-gallery .gl-grid{flex:1;display:grid;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);gap:5px}
|
|
23
|
+
.c-app-gallery .gl-tile{border:0;padding:0;border-radius:8px;background:var(--p);cursor:pointer;box-shadow:inset 0 0 0 .5px rgba(0,0,0,.1);transition:transform .24s cubic-bezier(.3,1.4,.5,1),filter .18s}
|
|
24
|
+
.c-app-gallery .gl-tile:hover{filter:brightness(1.06)}
|
|
25
|
+
.c-app-gallery .gl-tile:active{transform:scale(.9)}
|
|
26
|
+
.c-app-gallery .gl-tile:focus-visible,.c-app-gallery .gl-vbtn:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:1px}
|
|
27
|
+
.c-app-gallery .gl-view{position:absolute;inset:0;z-index:4;background:#13151b;display:flex;flex-direction:column;justify-content:space-between;padding:9px 10px;box-sizing:border-box;color:#fff;opacity:0;visibility:hidden;transform:scale(.88);transition:opacity .22s,transform .28s cubic-bezier(.2,.95,.3,1),visibility .22s}
|
|
28
|
+
.c-app-gallery.is-open .gl-view{opacity:1;visibility:visible;transform:none}
|
|
29
|
+
.c-app-gallery .gl-vtop{display:flex;align-items:center;justify-content:space-between;z-index:2}
|
|
30
|
+
.c-app-gallery .gl-cnt{padding:2px 8px;border-radius:9px;font-size:10.5px;font-weight:600;background:rgba(255,255,255,.16);font-variant-numeric:tabular-nums}
|
|
31
|
+
.c-app-gallery .gl-vbtn{width:24px;height:24px;border:0;border-radius:50%;padding:0;display:grid;place-items:center;color:#fff;background:rgba(255,255,255,.18);cursor:pointer;transition:transform .16s,background-color .16s}
|
|
32
|
+
.c-app-gallery .gl-vbtn:hover{background:rgba(255,255,255,.28)}
|
|
33
|
+
.c-app-gallery .gl-vbtn:active{transform:scale(.86)}
|
|
34
|
+
.c-app-gallery .gl-vbtn svg{width:13px;height:13px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
|
|
35
|
+
.c-app-gallery .gl-stage{position:relative;flex:1;margin:6px 0;border-radius:10px;background:var(--p);box-shadow:0 8px 20px rgba(0,0,0,.35);display:flex;align-items:center;justify-content:space-between;padding:0 6px}
|
|
36
|
+
.c-app-gallery .gl-stage.is-sw{animation:app-gallery-sw .24s cubic-bezier(.2,.9,.3,1)}
|
|
37
|
+
.c-app-gallery .gl-cap{text-align:center;font-size:11.5px;font-weight:600;letter-spacing:.02em;opacity:.92}
|
|
38
|
+
@keyframes app-gallery-sw{from{opacity:.5;transform:scale(.95)}to{opacity:1;transform:none}}
|
|
39
|
+
@media (prefers-reduced-motion:reduce){.c-app-gallery *{animation:none!important;transition:none!important}}
|
|
40
|
+
</style>
|
|
41
|
+
</head>
|
|
42
|
+
<body>
|
|
43
|
+
<div class="stage-fit">
|
|
44
|
+
<div class="c-app-gallery" data-comp="app-gallery">
|
|
45
|
+
<div class="gl-hd"><b>旅行相册</b><span>9 张</span></div>
|
|
46
|
+
<div class="gl-grid"><button class="gl-tile" type="button" data-i="0" aria-label="查看海岸日落" style="--p:radial-gradient(circle at 70% 34%,#fef08a 0 14%,transparent 16%),linear-gradient(180deg,#fb923c 0%,#f43f5e 54%,#1e3a8a 55%,#0f172a 100%)"></button><button class="gl-tile" type="button" data-i="1" aria-label="查看青翠山岚" style="--p:radial-gradient(circle at 26% 28%,#fff 0 11%,transparent 13%),linear-gradient(164deg,transparent 52%,#047857 53%),linear-gradient(15deg,#065f46 42%,transparent 43%),linear-gradient(180deg,#bae6fd,#38bdf8)"></button><button class="gl-tile" type="button" data-i="2" aria-label="查看落日沙丘" style="--p:radial-gradient(circle at 50% 30%,#fde047 0 13%,transparent 15%),linear-gradient(170deg,transparent 56%,#d97706 57%),linear-gradient(14deg,#b45309 45%,transparent 46%),linear-gradient(180deg,#fed7aa,#fb923c)"></button><button class="gl-tile" type="button" data-i="3" aria-label="查看星空露营" style="--p:radial-gradient(circle at 22% 24%,#fff 0 2px,transparent 3px),radial-gradient(circle at 75% 20%,#fff 0 2.5px,transparent 3.5px),radial-gradient(circle at 54% 32%,#fef08a 0 2px,transparent 3px),linear-gradient(166deg,transparent 60%,#1e293b 61%),linear-gradient(180deg,#0f172a,#312e81)"></button><button class="gl-tile" type="button" data-i="4" aria-label="查看秋日红枫" style="--p:radial-gradient(circle at 72% 28%,#fef08a 0 11%,transparent 13%),linear-gradient(166deg,transparent 52%,#be123c 53%),linear-gradient(14deg,#e11d48 44%,transparent 45%),linear-gradient(180deg,#ffedd5,#fda4af)"></button><button class="gl-tile" type="button" data-i="5" aria-label="查看暮色花田" style="--p:linear-gradient(180deg,#e0e7ff 0%,#a78bfa 56%,#5b21b6 57%,#3b0764 100%)"></button><button class="gl-tile" type="button" data-i="6" aria-label="查看珊瑚浅海" style="--p:radial-gradient(circle at 28% 28%,#fef9c3 0 12%,transparent 14%),linear-gradient(174deg,transparent 50%,#0d9488 51%,#0f766e 74%,#115e59 100%),linear-gradient(180deg,#7dd3fc,#2dd4bf)"></button><button class="gl-tile" type="button" data-i="7" aria-label="查看雪山倒影" style="--p:linear-gradient(155deg,transparent 54%,#f8fafc 55%,#cbd5e1 70%),linear-gradient(25deg,#e2e8f0 44%,transparent 45%),linear-gradient(180deg,#60a5fa,#1d4ed8)"></button><button class="gl-tile" type="button" data-i="8" aria-label="查看金黄麦浪" style="--p:radial-gradient(circle at 76% 28%,#fffbeb 0 12%,transparent 14%),linear-gradient(176deg,transparent 54%,#eab308 55%,#ca8a04 100%),linear-gradient(180deg,#93c5fd,#e0f2fe)"></button></div>
|
|
47
|
+
<div class="gl-view" aria-hidden="true">
|
|
48
|
+
<div class="gl-vtop"><span class="gl-cnt">5 / 9</span><button class="gl-vbtn gl-close" type="button" aria-label="关闭大图"><svg viewBox="0 0 16 16"><path d="M4 4l8 8M12 4l-8 8"/></svg></button></div>
|
|
49
|
+
<div class="gl-stage" style="--p:radial-gradient(circle at 72% 28%,#fef08a 0 11%,transparent 13%),linear-gradient(166deg,transparent 52%,#be123c 53%),linear-gradient(14deg,#e11d48 44%,transparent 45%),linear-gradient(180deg,#ffedd5,#fda4af)">
|
|
50
|
+
<button class="gl-vbtn gl-prev" type="button" aria-label="上一张"><svg viewBox="0 0 16 16"><path d="M10 3.5L5.5 8l4.5 4.5"/></svg></button>
|
|
51
|
+
<button class="gl-vbtn gl-next" type="button" aria-label="下一张"><svg viewBox="0 0 16 16"><path d="M6 3.5L10.5 8 6 12.5"/></svg></button>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="gl-cap">秋日红枫</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
<script data-comp>
|
|
58
|
+
/* 九宫格看图:点缩略图展开大图预览,支持左右切换与关闭 */
|
|
59
|
+
(() => {
|
|
60
|
+
const NAMES = ['海岸日落','青翠山岚','落日沙丘','星空露营','秋日红枫','暮色花田','珊瑚浅海','雪山倒影','金黄麦浪']
|
|
61
|
+
document.querySelectorAll('.c-app-gallery').forEach((el) => {
|
|
62
|
+
const tiles = [...el.querySelectorAll('.gl-tile')]
|
|
63
|
+
const view = el.querySelector('.gl-view')
|
|
64
|
+
const stage = el.querySelector('.gl-stage')
|
|
65
|
+
const cnt = el.querySelector('.gl-cnt')
|
|
66
|
+
const cap = el.querySelector('.gl-cap')
|
|
67
|
+
let cur = 4
|
|
68
|
+
const show = (i, anim = true) => {
|
|
69
|
+
cur = (i + tiles.length) % tiles.length
|
|
70
|
+
stage.style.setProperty('--p', tiles[cur].style.getPropertyValue('--p'))
|
|
71
|
+
cnt.textContent = `${cur + 1} / ${tiles.length}`
|
|
72
|
+
cap.textContent = NAMES[cur]
|
|
73
|
+
if (anim) { stage.classList.remove('is-sw'); void stage.offsetWidth; stage.classList.add('is-sw') }
|
|
74
|
+
}
|
|
75
|
+
const open = (i) => { show(i, false); el.classList.add('is-open'); view.setAttribute('aria-hidden', 'false') }
|
|
76
|
+
const close = () => { el.classList.remove('is-open'); view.setAttribute('aria-hidden', 'true') }
|
|
77
|
+
tiles.forEach((t, i) => t.addEventListener('click', () => open(i)))
|
|
78
|
+
el.querySelector('.gl-prev').addEventListener('click', (e) => { e.stopPropagation(); show(cur - 1, true) })
|
|
79
|
+
el.querySelector('.gl-next').addEventListener('click', (e) => { e.stopPropagation(); show(cur + 1, true) })
|
|
80
|
+
el.querySelector('.gl-close').addEventListener('click', (e) => { e.stopPropagation(); close() })
|
|
81
|
+
el.glOpen = open; el.glStep = (d) => show(cur + d, true); el.glClose = close
|
|
82
|
+
})
|
|
83
|
+
})()
|
|
84
|
+
</script>
|
|
85
|
+
<script data-stage>
|
|
86
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
87
|
+
(() => {
|
|
88
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
89
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
90
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
91
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
92
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
93
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
94
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
95
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
96
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
97
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
98
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
99
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
100
|
+
// ===== 只改这一段 =====
|
|
101
|
+
const DEMO = {
|
|
102
|
+
settle () { el.glClose() },
|
|
103
|
+
loop (later) {
|
|
104
|
+
later(() => el.glOpen(4), 700)
|
|
105
|
+
later(() => el.glStep(1), 1750)
|
|
106
|
+
later(() => el.glStep(1), 2750)
|
|
107
|
+
later(() => el.glClose(), 3850)
|
|
108
|
+
later(() => DEMO.loop(later), 4700)
|
|
109
|
+
},
|
|
110
|
+
stop () {},
|
|
111
|
+
}
|
|
112
|
+
// =====================
|
|
113
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
114
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
115
|
+
addEventListener('message', (e) => {
|
|
116
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
117
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
118
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
119
|
+
})
|
|
120
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
121
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
122
|
+
})()
|
|
123
|
+
</script>
|
|
124
|
+
</body>
|
|
125
|
+
</html>
|
|
@@ -0,0 +1,138 @@
|
|
|
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">
|
|
6
|
+
<title>字母索引</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"app-index","zh":"字母索引","en":"Index Bar","cat":"mobile","desc":"按住右侧字母条上下滑动,左侧浮现水滴气泡,联系人列表同步跳转","desc_en":"Drag the right-edge alphabet rail to show a teardrop indicator and jump across contact groups","needs":"js","play":"drag","hint":"拖右侧字母","hint_en":"Drag letters","source":{"name":"Framework7","url":"https://github.com/framework7io/framework7/blob/master/src/core/components/list-index/list-index.less","license":"MIT","author":"2014 Vladimir Kharlampidi"},"prompt":"通讯录字母索引条:宽 276px 高 172px 圆角 18px 的 --color-surface 卡片,参照 Framework7 list-index.less 与 list-index-ios.less 的右侧竖排字母条及旋转 45° 的水滴形高亮气泡。左侧为按 A 到 Z 分组的联系人列表(带首字彩色头像与头衔),右侧 22px 宽字母条排列 7 个首字母,当前选中项显示 15px --color-primary 圆形底。点击或按住字母条上下拖,水滴气泡紧随手指位置弹出显示当前字母,联系人列表同步平滑定位到对应分组。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary。","prompt_en":"Contact alphabet index bar: 276x172 --color-surface card (18px radius) adapted from Framework7 list-index.less and list-index-ios.less, with a right-edge letter rail and 45deg rotated teardrop indicator. Dragging or tapping along the 20px rail highlights the active letter in a --color-primary circle, pops the teardrop bubble beside the pointer, and jumps the contact list to that group. Reads --color-surface / --color-text / --color-muted / --color-line / --color-primary."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 字母索引 改写自 Framework7(MIT,© 2014 Vladimir Kharlampidi,https://github.com/framework7io/framework7)的 list-index.less 与 list-index-ios.less:右侧居中竖排字母条与旋转 45° 水滴形提示气泡;补写分组列表联动与指针拖拽。
|
|
18
|
+
读 --color-surface / --color-text / --color-muted / --color-line / --color-primary */
|
|
19
|
+
.c-app-index{position:relative;width:276px;height:172px;border-radius:18px;overflow:hidden;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.3);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-app-index .ix-list{position:absolute;inset:0 26px 0 0;overflow:hidden;scroll-behavior:smooth}
|
|
21
|
+
.c-app-index .ix-hd{padding:4px 12px;font-size:10.5px;font-weight:700;color:var(--color-primary,#0a84ff);background:color-mix(in srgb,var(--color-text,#141413) 4%,var(--color-surface,#fff));border-bottom:.5px solid var(--color-line,rgba(0,0,0,.07))}
|
|
22
|
+
.c-app-index .ix-row{display:flex;align-items:center;gap:9px;padding:7px 12px;position:relative}
|
|
23
|
+
.c-app-index .ix-row+.ix-row::before{content:"";position:absolute;left:47px;right:8px;top:0;height:.5px;background:var(--color-line,rgba(0,0,0,.08))}
|
|
24
|
+
.c-app-index .ix-av{flex:none;width:26px;height:26px;border-radius:50%;display:grid;place-items:center;font-style:normal;font-size:11.5px;font-weight:700;color:#fff;background:var(--k)}
|
|
25
|
+
.c-app-index .ix-tx{min-width:0;display:grid;gap:1px}
|
|
26
|
+
.c-app-index .ix-tx b{font-size:12px;font-weight:600;line-height:1.2}
|
|
27
|
+
.c-app-index .ix-tx span{font-size:10px;color:var(--color-muted,#76756f)}
|
|
28
|
+
.c-app-index .ix-rail{position:absolute;right:4px;top:10px;bottom:10px;width:20px;display:flex;flex-direction:column;justify-content:space-between;align-items:center;padding:6px 0;box-sizing:border-box;border-radius:10px;background:color-mix(in srgb,var(--color-text,#141413) 4%,transparent);touch-action:none;cursor:ns-resize;z-index:3}
|
|
29
|
+
.c-app-index .ix-rail:focus-visible{outline:2px solid var(--color-primary,#0a84ff)}
|
|
30
|
+
.c-app-index .ix-let{width:16px;height:16px;border-radius:50%;display:grid;place-items:center;font-size:9.5px;font-weight:700;color:var(--color-primary,#0a84ff);transition:background-color .16s,color .16s,transform .16s}
|
|
31
|
+
.c-app-index .ix-let.is-on{background:var(--color-primary,#0a84ff);color:#fff;transform:scale(1.08)}
|
|
32
|
+
.c-app-index .ix-bub{position:absolute;right:34px;top:0;width:34px;height:34px;border-radius:50%;display:grid;place-items:center;font-size:15px;font-weight:700;color:#fff;background:var(--color-primary,#0a84ff);box-shadow:0 6px 16px -4px color-mix(in srgb,var(--color-primary,#0a84ff) 55%,transparent);pointer-events:none;z-index:4;opacity:0;transform:translateY(var(--y,12px)) scale(.5);transition:opacity .16s,transform .18s cubic-bezier(.2,1.2,.4,1)}
|
|
33
|
+
.c-app-index .ix-bub::before{content:"";position:absolute;inset:0;border-radius:50% 0 50% 50%;background:inherit;transform:rotate(45deg);z-index:-1}
|
|
34
|
+
.c-app-index.is-pop .ix-bub{opacity:1;transform:translateY(var(--y,12px)) scale(1)}
|
|
35
|
+
@media (prefers-reduced-motion:reduce){.c-app-index *{transition:none!important;scroll-behavior:auto!important}}
|
|
36
|
+
</style>
|
|
37
|
+
</head>
|
|
38
|
+
<body>
|
|
39
|
+
<div class="stage-fit">
|
|
40
|
+
<div class="c-app-index" data-comp="app-index">
|
|
41
|
+
<div class="ix-list" aria-label="联系人列表"><div class="ix-grp" data-l="A"><div class="ix-hd">A</div><div class="ix-row"><i class="ix-av" style="--k:#0a84ff">安</i><div class="ix-tx"><b>安宁</b><span>产品经理</span></div></div><div class="ix-row"><i class="ix-av" style="--k:#5e5ce6">安</i><div class="ix-tx"><b>安然</b><span>插画师</span></div></div></div><div class="ix-grp" data-l="C"><div class="ix-hd">C</div><div class="ix-row"><i class="ix-av" style="--k:#30b35a">陈</i><div class="ix-tx"><b>陈明</b><span>研发顾问</span></div></div><div class="ix-row"><i class="ix-av" style="--k:#f97316">程</i><div class="ix-tx"><b>程远</b><span>视觉设计</span></div></div></div><div class="ix-grp" data-l="H"><div class="ix-hd">H</div><div class="ix-row"><i class="ix-av" style="--k:#ec4899">何</i><div class="ix-tx"><b>何清</b><span>活动策划</span></div></div><div class="ix-row"><i class="ix-av" style="--k:#14b8a6">黄</i><div class="ix-tx"><b>黄晓</b><span>音频编辑</span></div></div></div><div class="ix-grp" data-l="L"><div class="ix-hd">L</div><div class="ix-row"><i class="ix-av" style="--k:#ff375f">林</i><div class="ix-tx"><b>林小满</b><span>咖啡主理人</span></div></div><div class="ix-row"><i class="ix-av" style="--k:#6366f1">陆</i><div class="ix-tx"><b>陆寻</b><span>摄影师</span></div></div></div><div class="ix-grp" data-l="S"><div class="ix-hd">S</div><div class="ix-row"><i class="ix-av" style="--k:#eab308">沈</i><div class="ix-tx"><b>沈知意</b><span>图书编辑</span></div></div><div class="ix-row"><i class="ix-av" style="--k:#0ea5e9">苏</i><div class="ix-tx"><b>苏杭</b><span>建筑师</span></div></div></div><div class="ix-grp" data-l="W"><div class="ix-hd">W</div><div class="ix-row"><i class="ix-av" style="--k:#10b981">王</i><div class="ix-tx"><b>王思远</b><span>前端工程师</span></div></div><div class="ix-row"><i class="ix-av" style="--k:#8b5cf6">吴</i><div class="ix-tx"><b>吴悠</b><span>交互设计</span></div></div></div><div class="ix-grp" data-l="Z"><div class="ix-hd">Z</div><div class="ix-row"><i class="ix-av" style="--k:#f43f5e">周</i><div class="ix-tx"><b>周明远</b><span>项目负责人</span></div></div><div class="ix-row"><i class="ix-av" style="--k:#3b82f6">赵</i><div class="ix-tx"><b>赵溪</b><span>运营经理</span></div></div></div></div>
|
|
42
|
+
<div class="ix-bub" aria-hidden="true">A</div>
|
|
43
|
+
<div class="ix-rail" tabindex="0" role="slider" aria-label="字母索引" aria-valuemin="0" aria-valuemax="6" aria-valuenow="0"><span class="ix-let is-on" data-i="0">A</span><span class="ix-let" data-i="1">C</span><span class="ix-let" data-i="2">H</span><span class="ix-let" data-i="3">L</span><span class="ix-let" data-i="4">S</span><span class="ix-let" data-i="5">W</span><span class="ix-let" data-i="6">Z</span></div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<script data-comp>
|
|
47
|
+
/* 字母索引:点按或拖右侧字母条,弹出水滴气泡并把对应分组滚到顶部 */
|
|
48
|
+
(() => {
|
|
49
|
+
document.querySelectorAll('.c-app-index').forEach((el) => {
|
|
50
|
+
const list = el.querySelector('.ix-list')
|
|
51
|
+
const rail = el.querySelector('.ix-rail')
|
|
52
|
+
const lets = [...rail.querySelectorAll('.ix-let')]
|
|
53
|
+
const grps = [...list.querySelectorAll('.ix-grp')]
|
|
54
|
+
const bub = el.querySelector('.ix-bub')
|
|
55
|
+
let cur = 0, down = false, hideT = 0
|
|
56
|
+
const go = (i, pop = false, instant = false) => {
|
|
57
|
+
i = Math.max(0, Math.min(lets.length - 1, i))
|
|
58
|
+
cur = i
|
|
59
|
+
lets.forEach((l, k) => l.classList.toggle('is-on', k === i))
|
|
60
|
+
rail.setAttribute('aria-valuenow', i)
|
|
61
|
+
const ch = lets[i].textContent
|
|
62
|
+
bub.textContent = ch
|
|
63
|
+
const y = 12 + (i / (lets.length - 1)) * 116
|
|
64
|
+
bub.style.setProperty('--y', y.toFixed(1) + 'px')
|
|
65
|
+
el.classList.toggle('is-pop', pop)
|
|
66
|
+
if (instant) list.style.scrollBehavior = 'auto'
|
|
67
|
+
list.scrollTop = grps[i].offsetTop
|
|
68
|
+
if (instant) { void list.offsetHeight; list.style.scrollBehavior = '' }
|
|
69
|
+
}
|
|
70
|
+
const atY = (cy) => {
|
|
71
|
+
const r = rail.getBoundingClientRect()
|
|
72
|
+
const f = Math.max(0, Math.min(.999, (cy - r.top) / (r.height || 1)))
|
|
73
|
+
return Math.floor(f * lets.length)
|
|
74
|
+
}
|
|
75
|
+
rail.addEventListener('pointerdown', (e) => {
|
|
76
|
+
clearTimeout(hideT); down = true
|
|
77
|
+
rail.setPointerCapture(e.pointerId)
|
|
78
|
+
go(atY(e.clientY), true, true)
|
|
79
|
+
})
|
|
80
|
+
rail.addEventListener('pointermove', (e) => { if (down) go(atY(e.clientY), true, true) })
|
|
81
|
+
const end = () => {
|
|
82
|
+
if (!down) return; down = false
|
|
83
|
+
hideT = setTimeout(() => el.classList.remove('is-pop'), 260)
|
|
84
|
+
}
|
|
85
|
+
rail.addEventListener('pointerup', end); rail.addEventListener('pointercancel', end)
|
|
86
|
+
rail.addEventListener('keydown', (e) => {
|
|
87
|
+
const d = { ArrowDown: 1, ArrowUp: -1 }[e.key]
|
|
88
|
+
if (!d) return; e.preventDefault()
|
|
89
|
+
clearTimeout(hideT); go(cur + d, true, false)
|
|
90
|
+
hideT = setTimeout(() => el.classList.remove('is-pop'), 500)
|
|
91
|
+
})
|
|
92
|
+
el.ixGo = go
|
|
93
|
+
el.ixClear = () => { clearTimeout(hideT); el.classList.remove('is-pop') }
|
|
94
|
+
})
|
|
95
|
+
})()
|
|
96
|
+
</script>
|
|
97
|
+
<script data-stage>
|
|
98
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
99
|
+
(() => {
|
|
100
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
101
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
102
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
103
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
104
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
105
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
106
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
107
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
108
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
109
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
110
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
111
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
112
|
+
// ===== 只改这一段 =====
|
|
113
|
+
const DEMO = {
|
|
114
|
+
settle () { el.ixClear(); el.ixGo(0, false, true) },
|
|
115
|
+
loop (later) {
|
|
116
|
+
later(() => el.ixGo(1, true, false), 650)
|
|
117
|
+
later(() => el.ixGo(3, true, false), 1450)
|
|
118
|
+
later(() => el.ixGo(5, true, false), 2250)
|
|
119
|
+
later(() => el.ixClear(), 3450)
|
|
120
|
+
later(() => el.ixGo(0, false, false), 4100)
|
|
121
|
+
later(() => DEMO.loop(later), 4900)
|
|
122
|
+
},
|
|
123
|
+
stop () { el.ixClear() },
|
|
124
|
+
}
|
|
125
|
+
// =====================
|
|
126
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
127
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
128
|
+
addEventListener('message', (e) => {
|
|
129
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
130
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
131
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
132
|
+
})
|
|
133
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
134
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
135
|
+
})()
|
|
136
|
+
</script>
|
|
137
|
+
</body>
|
|
138
|
+
</html>
|
|
@@ -0,0 +1,138 @@
|
|
|
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">
|
|
6
|
+
<title>大标题导航</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"app-largetitle","zh":"大标题导航","en":"Large Title Nav","cat":"mobile","desc":"顶部大号标题随列表上滑平滑缩小收进顶栏,顶部出现发丝线","desc_en":"Large iOS-style title smoothly collapses into the compact top navbar while scrolling","needs":"js","play":"drag","hint":"上下拖列表","hint_en":"Drag list","source":{"name":"Framework7","url":"https://github.com/framework7io/framework7/blob/master/src/core/components/navbar/navbar.less","license":"MIT","author":"2014 Vladimir Kharlampidi"},"prompt":"移动端大标题导航栏:宽 258px 高 172px 圆角 20px 的 --color-surface 预览屏,照 Framework7 navbar.less 的折叠进度做法。顶栏高 36px,含返回箭头、新建按钮与默认透明的居中标题;下方 22px 粗体大标题与列表上拖 36px 内把 --lt-p 从 0 推到 1,大标题上移缩淡,顶栏标题与 0.5px 发丝线渐显。用 overflow:hidden 加指针拖拽,读 --color-surface / --color-text / --color-muted / --color-line / --color-primary。","prompt_en":"Mobile large-title navbar: 258x172 --color-surface card (20px radius) adapted from Framework7 navbar.less collapse progress. A 36px bar holds back chevron, plus button, and hidden centered title. Dragging up 36px maps --lt-p 0 to 1, shrinking and fading the 22px title while fading in the compact title and .5px divider. Uses overflow:hidden with pointer drag. Reads --color-surface / --color-text / --color-muted / --color-line / --color-primary."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 大标题导航 改写自 Framework7(MIT,© 2014 Vladimir Kharlampidi,https://github.com/framework7io/framework7)的 navbar.less:--f7-navbar-large-collapse-progress 控制大标题位移隐去、紧凑标题显现与底部分隔线;改用单文件自定义属性 --lt-p 与指针拖拽滚动。
|
|
18
|
+
读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-danger / --color-warning / --color-success */
|
|
19
|
+
.c-app-largetitle{--lt-p:0;position:relative;width:258px;height:172px;border-radius:20px;overflow:hidden;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.3);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-app-largetitle .lt-bar{position:absolute;left:0;right:0;top:0;height:36px;z-index:4;display:flex;align-items:center;justify-content:space-between;padding:0 12px;box-sizing:border-box;background:color-mix(in srgb,var(--color-surface,#fff) 92%,transparent);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}
|
|
21
|
+
.c-app-largetitle .lt-bar::after{content:"";position:absolute;left:0;right:0;bottom:0;height:.5px;background:var(--color-line,rgba(0,0,0,.1));opacity:var(--lt-p)}
|
|
22
|
+
.c-app-largetitle .lt-left{display:inline-flex;align-items:center;gap:2px;font-size:12px;font-weight:500;color:var(--color-primary,#0a84ff)}
|
|
23
|
+
.c-app-largetitle .lt-left svg,.c-app-largetitle .lt-act svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
|
|
24
|
+
.c-app-largetitle .lt-act{width:24px;height:24px;border-radius:50%;display:grid;place-items:center;color:var(--color-primary,#0a84ff);background:color-mix(in srgb,var(--color-primary,#0a84ff) 12%,transparent)}
|
|
25
|
+
.c-app-largetitle .lt-sm{position:absolute;left:50%;top:50%;font-size:13.5px;font-weight:600;letter-spacing:-.01em;white-space:nowrap;opacity:var(--lt-p);transform:translate(-50%,calc(-50% + (1 - var(--lt-p))*7px));pointer-events:none}
|
|
26
|
+
.c-app-largetitle .lt-scroll{position:absolute;inset:0;padding:36px 12px 10px;box-sizing:border-box;overflow:hidden;touch-action:none;cursor:grab}
|
|
27
|
+
.c-app-largetitle .lt-scroll:active{cursor:grabbing}
|
|
28
|
+
.c-app-largetitle .lt-scroll:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:-2px}
|
|
29
|
+
.c-app-largetitle .lt-big{padding:2px 2px 8px;font-size:22px;font-weight:700;line-height:1.2;letter-spacing:-.02em;transform-origin:left center;opacity:calc(1 - var(--lt-p)*1.25);transform:translate3d(0,calc(var(--lt-p)*-10px),0) scale(calc(1 - var(--lt-p)*.16))}
|
|
30
|
+
.c-app-largetitle .lt-list{border-radius:12px;background:color-mix(in srgb,var(--color-text,#141413) 4%,var(--color-surface,#fff));box-shadow:inset 0 0 0 .5px var(--color-line,rgba(0,0,0,.08));overflow:hidden}
|
|
31
|
+
.c-app-largetitle .lt-row{display:flex;align-items:center;gap:9px;padding:8px 10px;position:relative}
|
|
32
|
+
.c-app-largetitle .lt-row+.lt-row::before{content:"";position:absolute;left:45px;right:10px;top:0;height:.5px;background:var(--color-line,rgba(0,0,0,.08))}
|
|
33
|
+
.c-app-largetitle .lt-ic{flex:none;width:26px;height:26px;border-radius:7px;display:grid;place-items:center;color:var(--k);background:color-mix(in srgb,var(--k) 15%,transparent)}
|
|
34
|
+
.c-app-largetitle .lt-ic svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
|
|
35
|
+
.c-app-largetitle .lt-tx{flex:1;min-width:0;display:grid;gap:1px}
|
|
36
|
+
.c-app-largetitle .lt-tx b{font-size:12px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
37
|
+
.c-app-largetitle .lt-tx span{font-size:10px;color:var(--color-muted,#76756f)}
|
|
38
|
+
.c-app-largetitle .lt-ar{width:5px;height:5px;border:solid var(--color-muted,#76756f);border-width:1.4px 1.4px 0 0;transform:rotate(45deg);opacity:.55}
|
|
39
|
+
@media (prefers-reduced-motion:reduce){.c-app-largetitle *{transition:none!important}}
|
|
40
|
+
</style>
|
|
41
|
+
</head>
|
|
42
|
+
<body>
|
|
43
|
+
<div class="stage-fit">
|
|
44
|
+
<div class="c-app-largetitle" data-comp="app-largetitle">
|
|
45
|
+
<div class="lt-bar" aria-hidden="true">
|
|
46
|
+
<span class="lt-left"><svg viewBox="0 0 20 20"><path d="M12.5 4.5L7 10l5.5 5.5"/></svg>文件夹</span>
|
|
47
|
+
<span class="lt-sm">备忘录</span>
|
|
48
|
+
<span class="lt-act"><svg viewBox="0 0 20 20"><path d="M10 4.5v11M4.5 10h11"/></svg></span>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="lt-scroll" tabindex="0" aria-label="备忘录列表">
|
|
51
|
+
<div class="lt-big">备忘录</div>
|
|
52
|
+
<div class="lt-list"><div class="lt-row"><i class="lt-ic" style="--k:var(--color-warning,#ffb340)"><svg viewBox="0 0 24 24"><path d="M12 4v2m0 12v2M4 12h2m12 0h2m-2.3-5.7l-1.4 1.4M7.7 16.3l-1.4 1.4m0-11.4l1.4 1.4m8.6 8.6l1.4 1.4"/><circle cx="12" cy="12" r="3.5"/></svg></i><div class="lt-tx"><b>晨间灵感随记</b><span>今天 09:20</span></div><i class="lt-ar"></i></div><div class="lt-row"><i class="lt-ic" style="--k:var(--color-success,#30b35a)"><svg viewBox="0 0 24 24"><path d="M3 18l9-13 9 13H3zm9-7v7"/></svg></i><div class="lt-tx"><b>周末山野露营清单</b><span>昨天 21:05</span></div><i class="lt-ar"></i></div><div class="lt-row"><i class="lt-ic" style="--k:var(--color-primary,#0a84ff)"><svg viewBox="0 0 24 24"><path d="M5 4h11a2 2 0 0 1 2 2v14l-6-3.2L6 20V6a2 2 0 0 1-1-2z"/></svg></i><div class="lt-tx"><b>年度书单摘录</b><span>周四</span></div><i class="lt-ar"></i></div><div class="lt-row"><i class="lt-ic" style="--k:var(--color-danger,#ff375f)"><svg viewBox="0 0 24 24"><path d="M6 12h12v4a6 6 0 0 1-12 0v-4zm3-6h6v6H9z"/></svg></i><div class="lt-tx"><b>厨房常备调料</b><span>11月24日</span></div><i class="lt-ar"></i></div><div class="lt-row"><i class="lt-ic" style="--k:#6366f1"><svg viewBox="0 0 24 24"><rect x="4" y="6" width="16" height="4" rx="1"/><path d="M6 10v8a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-8"/></svg></i><div class="lt-tx"><b>冬季收纳要点</b><span>11月20日</span></div><i class="lt-ar"></i></div><div class="lt-row"><i class="lt-ic" style="--k:#14b8a6"><svg viewBox="0 0 24 24"><path d="M12 20s6-5 6-10a6 6 0 1 0-12 0c0 5 6 10 6 10z"/><circle cx="12" cy="10" r="2"/></svg></i><div class="lt-tx"><b>城市散步路线</b><span>11月16日</span></div><i class="lt-ar"></i></div></div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
<script data-comp>
|
|
57
|
+
/* 大标题导航:滚动 0→36px 线性映射 --lt-p 从 0 到 1,支持指针拖拽和上下方向键 */
|
|
58
|
+
(() => {
|
|
59
|
+
document.querySelectorAll('.c-app-largetitle').forEach((el) => {
|
|
60
|
+
const sc = el.querySelector('.lt-scroll')
|
|
61
|
+
const paint = () => {
|
|
62
|
+
const p = Math.max(0, Math.min(1, sc.scrollTop / 36))
|
|
63
|
+
el.style.setProperty('--lt-p', p.toFixed(3))
|
|
64
|
+
}
|
|
65
|
+
sc.addEventListener('scroll', paint, { passive: true })
|
|
66
|
+
let drag = null
|
|
67
|
+
sc.addEventListener('pointerdown', (e) => {
|
|
68
|
+
drag = { y: e.clientY, top: sc.scrollTop, k: 172 / (el.getBoundingClientRect().height || 172) }
|
|
69
|
+
sc.setPointerCapture(e.pointerId)
|
|
70
|
+
})
|
|
71
|
+
sc.addEventListener('pointermove', (e) => {
|
|
72
|
+
if (!drag) return
|
|
73
|
+
sc.scrollTop = drag.top - (e.clientY - drag.y) * drag.k
|
|
74
|
+
paint()
|
|
75
|
+
})
|
|
76
|
+
const end = () => { drag = null }
|
|
77
|
+
sc.addEventListener('pointerup', end)
|
|
78
|
+
sc.addEventListener('pointercancel', end)
|
|
79
|
+
sc.addEventListener('keydown', (e) => {
|
|
80
|
+
const d = { ArrowDown: 28, ArrowUp: -28 }[e.key]
|
|
81
|
+
if (d) { e.preventDefault(); sc.scrollTop += d; paint() }
|
|
82
|
+
})
|
|
83
|
+
el.ltPaint = paint
|
|
84
|
+
paint()
|
|
85
|
+
})
|
|
86
|
+
})()
|
|
87
|
+
</script>
|
|
88
|
+
<script data-stage>
|
|
89
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
90
|
+
(() => {
|
|
91
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
92
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
93
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
94
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
95
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
96
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
97
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
98
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
99
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
100
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
101
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
102
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
103
|
+
// ===== 只改这一段 =====
|
|
104
|
+
const sc = el.querySelector('.lt-scroll'); let raf = 0
|
|
105
|
+
const roll = (to, ms) => {
|
|
106
|
+
cancelAnimationFrame(raf)
|
|
107
|
+
const from = sc.scrollTop, t0 = performance.now()
|
|
108
|
+
const step = (t) => {
|
|
109
|
+
const k = Math.min(1, (t - t0) / ms)
|
|
110
|
+
sc.scrollTop = from + (to - from) * k * k * (3 - 2 * k)
|
|
111
|
+
if (el.ltPaint) el.ltPaint()
|
|
112
|
+
if (k < 1) raf = requestAnimationFrame(step)
|
|
113
|
+
}
|
|
114
|
+
raf = requestAnimationFrame(step)
|
|
115
|
+
}
|
|
116
|
+
const DEMO = {
|
|
117
|
+
settle () { cancelAnimationFrame(raf); sc.scrollTop = 0; if (el.ltPaint) el.ltPaint() },
|
|
118
|
+
loop (later) {
|
|
119
|
+
later(() => roll(86, 1200), 650)
|
|
120
|
+
later(() => roll(0, 1000), 3100)
|
|
121
|
+
later(() => DEMO.loop(later), 4800)
|
|
122
|
+
},
|
|
123
|
+
stop () { cancelAnimationFrame(raf) },
|
|
124
|
+
}
|
|
125
|
+
// =====================
|
|
126
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
127
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
128
|
+
addEventListener('message', (e) => {
|
|
129
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
130
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
131
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
132
|
+
})
|
|
133
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
134
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
135
|
+
})()
|
|
136
|
+
</script>
|
|
137
|
+
</body>
|
|
138
|
+
</html>
|
|
@@ -0,0 +1,141 @@
|
|
|
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">
|
|
6
|
+
<title>新手引导页</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"app-onboard","zh":"新手引导页","en":"Onboarding Flow","cat":"mobile","desc":"三页横向滑动新手引导,跟手拖拽翻页,底部指示点随当前页拉成胶囊","desc_en":"Three-page swipeable onboarding flow with illustrations, expanding pill dots, and a Next button","needs":"js","play":"drag","hint":"左右滑翻页","hint_en":"Swipe pages","source":null,"prompt":"移动端三页新手引导页:宽 268px 高 172px 圆角 18px 的 --color-surface 卡片。上方横向三页轨道含内联 SVG 轻插画、粗体短标题与 --color-muted 说明,按住左右拖跟手移动,松手超 26px 吸附翻页(360ms)。底部左侧三颗指示点当前拉成 18×5px 胶囊,右侧「下一步」在末页切换为「立即开启」。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-success。","prompt_en":"Mobile 3-page onboarding flow: 268x172 --color-surface card (18px radius). Three swipeable slides feature inline SVG art, bold titles, and --color-muted subtitles, tracking drags 1:1 and snapping past 26px (360ms cubic-bezier(.22,1,.36,1)). Bottom row pairs 3 dots (active expands to an 18x5 pill) with a Next button turning into Start Now on page 3. Reads --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-success."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 新手引导页:三页跟手左右滑动轨道、内联 SVG 插画与胶囊指示点。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-warning / --color-success */
|
|
18
|
+
.c-app-onboard{position:relative;width:268px;height:172px;border-radius:18px;overflow:hidden;display:flex;flex-direction:column;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.3);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
19
|
+
.c-app-onboard .ob-stage{flex:1;overflow:hidden;touch-action:none;cursor:grab}
|
|
20
|
+
.c-app-onboard .ob-stage:active{cursor:grabbing}
|
|
21
|
+
.c-app-onboard .ob-stage:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:-2px}
|
|
22
|
+
.c-app-onboard .ob-track{display:flex;height:100%;will-change:transform;transition:transform .36s cubic-bezier(.22,1,.36,1)}
|
|
23
|
+
.c-app-onboard .ob-track.is-drag{transition:none}
|
|
24
|
+
.c-app-onboard .ob-slide{flex:none;width:100%;padding:10px 18px 4px;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:4px}
|
|
25
|
+
.c-app-onboard .ob-svg{width:84px;height:62px;flex:none}
|
|
26
|
+
.c-app-onboard .ob-slide b{font-size:14px;font-weight:700;line-height:1.25}
|
|
27
|
+
.c-app-onboard .ob-slide p{margin:0;font-size:11px;color:var(--color-muted,#76756f);line-height:1.3}
|
|
28
|
+
.c-app-onboard .ob-foot{height:42px;padding:0 14px;display:flex;align-items:center;justify-content:space-between;border-top:.5px solid var(--color-line,rgba(0,0,0,.07))}
|
|
29
|
+
.c-app-onboard .ob-dots{display:flex;align-items:center;gap:5px}
|
|
30
|
+
.c-app-onboard .ob-dot{width:6px;height:6px;border:0;padding:0;border-radius:3px;background:color-mix(in srgb,var(--color-text,#141413) 18%,transparent);cursor:pointer;transition:width .32s cubic-bezier(.3,1.25,.45,1),background-color .2s}
|
|
31
|
+
.c-app-onboard .ob-dot.is-on{width:18px;background:var(--color-primary,#0a84ff)}
|
|
32
|
+
.c-app-onboard .ob-btn{height:26px;padding:0 12px;border:0;border-radius:13px;background:var(--color-primary,#0a84ff);color:#fff;font:600 11px/1 var(--font-sans,system-ui);cursor:pointer;transition:transform .18s,background-color .2s}
|
|
33
|
+
.c-app-onboard .ob-btn:active{transform:scale(.92)}
|
|
34
|
+
.c-app-onboard .ob-btn.is-last{background:var(--color-success,#30b35a)}
|
|
35
|
+
.c-app-onboard button:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:2px}
|
|
36
|
+
@media (prefers-reduced-motion:reduce){.c-app-onboard *{transition:none!important}}
|
|
37
|
+
</style>
|
|
38
|
+
</head>
|
|
39
|
+
<body>
|
|
40
|
+
<div class="stage-fit">
|
|
41
|
+
<div class="c-app-onboard" data-comp="app-onboard">
|
|
42
|
+
<div class="ob-stage" tabindex="0" aria-label="新手引导">
|
|
43
|
+
<div class="ob-track"><div class="ob-slide ob-s0"><svg class="ob-svg" viewBox="0 0 88 66" aria-hidden="true"><circle cx="44" cy="34" r="28" fill="rgba(59,130,246,.14)"/><rect x="24" y="14" width="40" height="42" rx="9" fill="var(--color-surface,#fff)" stroke="var(--color-primary,#0a84ff)" stroke-width="1.8"/><path d="M33 27h22M33 35h16M33 43h12" stroke="var(--color-primary,#0a84ff)" stroke-width="2.2" stroke-linecap="round"/><circle cx="63" cy="17" r="7" fill="var(--color-warning,#ffb340)"/><path d="M63 13.5v7M59.5 17h7" stroke="#fff" stroke-width="1.8" stroke-linecap="round"/></svg><b>灵感随时记录</b><p>语音与图文自动整理归类</p></div><div class="ob-slide ob-s1"><svg class="ob-svg" viewBox="0 0 88 66" aria-hidden="true"><circle cx="44" cy="34" r="28" fill="rgba(48,179,90,.14)"/><rect x="22" y="16" width="44" height="38" rx="9" fill="var(--color-surface,#fff)" stroke="var(--color-success,#30b35a)" stroke-width="1.8"/><path d="M22 26h44M34 12v7M54 12v7" stroke="var(--color-success,#30b35a)" stroke-width="2.2" stroke-linecap="round"/><path d="M36 39l5.5 5.5L53 33" fill="none" stroke="var(--color-success,#30b35a)" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/></svg><b>日程智能提醒</b><p>重要节点提前温和告知</p></div><div class="ob-slide ob-s2"><svg class="ob-svg" viewBox="0 0 88 66" aria-hidden="true"><circle cx="44" cy="34" r="28" fill="rgba(99,102,241,.15)"/><rect x="18" y="16" width="38" height="28" rx="6" fill="var(--color-surface,#fff)" stroke="#6366f1" stroke-width="1.8"/><rect x="48" y="24" width="22" height="30" rx="5" fill="var(--color-surface,#fff)" stroke="var(--color-primary,#0a84ff)" stroke-width="1.8"/><circle cx="59" cy="49" r="1.6" fill="var(--color-primary,#0a84ff)"/><path d="M28 30h14" stroke="#6366f1" stroke-width="2.2" stroke-linecap="round"/></svg><b>多端无缝同步</b><p>手机平板随时接着上次看</p></div></div>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="ob-foot">
|
|
46
|
+
<div class="ob-dots" role="tablist" aria-label="引导页码">
|
|
47
|
+
<button class="ob-dot is-on" type="button" aria-label="第 1 页"></button>
|
|
48
|
+
<button class="ob-dot" type="button" aria-label="第 2 页"></button>
|
|
49
|
+
<button class="ob-dot" type="button" aria-label="第 3 页"></button>
|
|
50
|
+
</div>
|
|
51
|
+
<button class="ob-btn" type="button">下一步</button>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<script data-comp>
|
|
56
|
+
/* 新手引导页:支持左右拖拽跟手翻页、点指示点与下一步按钮切换 */
|
|
57
|
+
(() => {
|
|
58
|
+
const N = 3
|
|
59
|
+
document.querySelectorAll('.c-app-onboard').forEach((el) => {
|
|
60
|
+
const stage = el.querySelector('.ob-stage'), track = el.querySelector('.ob-track')
|
|
61
|
+
const dots = [...el.querySelectorAll('.ob-dot')], btn = el.querySelector('.ob-btn')
|
|
62
|
+
let cur = 0, drag = null
|
|
63
|
+
const go = (i, anim = true, dx = 0) => {
|
|
64
|
+
cur = (i + N) % N
|
|
65
|
+
track.classList.toggle('is-drag', !anim)
|
|
66
|
+
track.style.transform = `translate3d(calc(${-cur * 100}% + ${dx.toFixed(1)}px),0,0)`
|
|
67
|
+
dots.forEach((d, k) => d.classList.toggle('is-on', k === cur))
|
|
68
|
+
const last = cur === N - 1
|
|
69
|
+
btn.textContent = last ? '立即开启' : '下一步'
|
|
70
|
+
btn.classList.toggle('is-last', last)
|
|
71
|
+
}
|
|
72
|
+
stage.addEventListener('pointerdown', (e) => {
|
|
73
|
+
drag = { x: e.clientX, dx: 0, k: 268 / (el.getBoundingClientRect().width || 268) }
|
|
74
|
+
stage.setPointerCapture(e.pointerId)
|
|
75
|
+
})
|
|
76
|
+
stage.addEventListener('pointermove', (e) => {
|
|
77
|
+
if (!drag) return
|
|
78
|
+
drag.dx = (e.clientX - drag.x) * drag.k
|
|
79
|
+
track.classList.add('is-drag')
|
|
80
|
+
track.style.transform = `translate3d(calc(${-cur * 100}% + ${drag.dx.toFixed(1)}px),0,0)`
|
|
81
|
+
})
|
|
82
|
+
const end = () => {
|
|
83
|
+
if (!drag) return
|
|
84
|
+
const dx = drag.dx; drag = null
|
|
85
|
+
if (dx < -26) go(cur + 1, true)
|
|
86
|
+
else if (dx > 26) go(cur - 1, true)
|
|
87
|
+
else go(cur, true)
|
|
88
|
+
}
|
|
89
|
+
stage.addEventListener('pointerup', end); stage.addEventListener('pointercancel', end)
|
|
90
|
+
stage.addEventListener('keydown', (e) => {
|
|
91
|
+
if (e.key === 'ArrowRight') { e.preventDefault(); go(cur + 1, true) }
|
|
92
|
+
if (e.key === 'ArrowLeft') { e.preventDefault(); go(cur - 1, true) }
|
|
93
|
+
})
|
|
94
|
+
dots.forEach((d, i) => d.addEventListener('click', () => go(i, true)))
|
|
95
|
+
btn.addEventListener('click', () => go(cur + 1, true))
|
|
96
|
+
el.obGo = go
|
|
97
|
+
go(0, false)
|
|
98
|
+
})
|
|
99
|
+
})()
|
|
100
|
+
</script>
|
|
101
|
+
<script data-stage>
|
|
102
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
103
|
+
(() => {
|
|
104
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
105
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
106
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
107
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
108
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
109
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
110
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
111
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
112
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
113
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
114
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
115
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
116
|
+
// ===== 只改这一段 =====
|
|
117
|
+
const DEMO = {
|
|
118
|
+
settle () { el.obGo(0, false) },
|
|
119
|
+
loop (later) {
|
|
120
|
+
el.obGo(0, false)
|
|
121
|
+
later(() => el.obGo(1, true), 900)
|
|
122
|
+
later(() => el.obGo(2, true), 2300)
|
|
123
|
+
later(() => el.obGo(0, true), 3800)
|
|
124
|
+
later(() => DEMO.loop(later), 4700)
|
|
125
|
+
},
|
|
126
|
+
stop () {},
|
|
127
|
+
}
|
|
128
|
+
// =====================
|
|
129
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
130
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
131
|
+
addEventListener('message', (e) => {
|
|
132
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
133
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
134
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
135
|
+
})
|
|
136
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
137
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
138
|
+
})()
|
|
139
|
+
</script>
|
|
140
|
+
</body>
|
|
141
|
+
</html>
|