悄悄话流星十改:可连点多颗,多颗流星同时滑落 (v26100174)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<title>兜爸心选 · 孕育陪伴</title>
|
||||
<!-- V:26100173 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||
<!-- V:26100174 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||
<link rel="stylesheet" href="mama-box.css">
|
||||
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
|
||||
<!-- 共享助手:授权/跳商城/位置上报(分享卡片同步,见 docs/h5-auth-standard.md 第四节) -->
|
||||
|
||||
38
js/app.js
38
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26100173';
|
||||
var VER = '26100174';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -3352,7 +3352,8 @@
|
||||
const hsh = s => { let h = 7; for (const c of String(s)) h = (h * 31 + c.charCodeAt(0)) >>> 0; return h; };
|
||||
const card = $('#wsc');
|
||||
const seen = new Set();
|
||||
let cur = 0, mt = null;
|
||||
let cur = 0;
|
||||
const mts = new Map(); // 十改:可以连点多颗,多颗流星同时往下落;key = 星的序号
|
||||
function paintDeco() {
|
||||
const box = $('#wskStars');
|
||||
if (box.childElementCount) return;
|
||||
@@ -3401,16 +3402,16 @@
|
||||
}
|
||||
/* 七改(用户:「点一个流星底下就出现文字,好像就不用看流星上面写什么了」):
|
||||
内容卡改到流星划完才浮出来(小字回放 + 抱抱),先看流星、再看卡;中途换星就不出旧卡。 */
|
||||
function stopMeteor(done) {
|
||||
if (!mt) return;
|
||||
cancelAnimationFrame(mt.raf);
|
||||
mt.el.remove();
|
||||
mt.btn.classList.remove('flare', 'gone');
|
||||
mt.btn.classList.add('seen');
|
||||
const m = mt;
|
||||
mt = null;
|
||||
function stopMeteor(m, done) {
|
||||
if (!m || mts.get(m.i) !== m) return;
|
||||
cancelAnimationFrame(m.raf);
|
||||
m.el.remove();
|
||||
m.btn.classList.remove('flare', 'gone');
|
||||
m.btn.classList.add('seen');
|
||||
mts.delete(m.i);
|
||||
if (done) paintCard(m.it, m.i);
|
||||
}
|
||||
const stopAll = () => [...mts.values()].forEach(m => stopMeteor(m));
|
||||
/* 第一次进来:一闪一闪的提示,点过一次星星就永久收起 */
|
||||
const TIP = 'mmbox.whtip.v1';
|
||||
const tipEl = $('#wskTip');
|
||||
@@ -3421,8 +3422,7 @@
|
||||
}
|
||||
function launch(i) {
|
||||
const it = list()[i - 1];
|
||||
if (!it) return;
|
||||
stopMeteor();
|
||||
if (!it || mts.has(i)) return;
|
||||
cur = i;
|
||||
seen.add(it.id);
|
||||
$$('.wsk-st.hint', page).forEach(x => x.classList.remove('hint'));
|
||||
@@ -3460,7 +3460,7 @@
|
||||
const t0 = performance.now();
|
||||
const frame = now => {
|
||||
const t = now - t0;
|
||||
if (t < T0) { mt.raf = requestAnimationFrame(frame); return; }
|
||||
if (t < T0) { m.raf = requestAnimationFrame(frame); return; }
|
||||
btn.classList.add('gone');
|
||||
const tc = t - T0, dt = Math.max(0, tc - TR), u = Math.min(1, dt / TE);
|
||||
const s = v0 * tc + v0 * tc * tc / 16000 + .5 * A * dt * dt;
|
||||
@@ -3479,10 +3479,12 @@
|
||||
c.style.opacity = (Math.min(1, d / 26) * fade).toFixed(2);
|
||||
c.style.transform = 'translate(' + (x0 + dx * d).toFixed(1) + 'px,' + (y0 + dy * d).toFixed(1) + 'px) translate(-50%,-50%) rotate(' + rot.toFixed(1) + 'deg)';
|
||||
});
|
||||
if (u >= 1) { stopMeteor(true); return; }
|
||||
mt.raf = requestAnimationFrame(frame);
|
||||
if (u >= 1) { stopMeteor(m, true); return; }
|
||||
m.raf = requestAnimationFrame(frame);
|
||||
};
|
||||
mt = { el, btn, it, i, raf: requestAnimationFrame(frame) };
|
||||
const m = { el, btn, it, i, raf: 0 };
|
||||
mts.set(i, m);
|
||||
m.raf = requestAnimationFrame(frame);
|
||||
}
|
||||
function nextStar() {
|
||||
const l = list(), n = l.length;
|
||||
@@ -3518,7 +3520,7 @@
|
||||
launch(g.dataset.next ? nextStar() : +g.dataset.go);
|
||||
});
|
||||
function openPage() {
|
||||
stopMeteor();
|
||||
stopAll();
|
||||
cur = 0;
|
||||
card.classList.remove('show');
|
||||
paintPage();
|
||||
@@ -3529,7 +3531,7 @@
|
||||
haptic();
|
||||
}
|
||||
function closePage() {
|
||||
stopMeteor();
|
||||
stopAll();
|
||||
drawer(false);
|
||||
page.classList.remove('show');
|
||||
page.setAttribute('aria-hidden', 'true');
|
||||
|
||||
Reference in New Issue
Block a user