revert(diy): 撤销贴纸坐标钳制,恢复可拖出画布外自由摆放

需求决定(2026-09-12):负坐标/超出画布为合法摆放状态;
重叠误报根因是尺寸语义(已由归一化修复),坐标钳制一并移除。
文档同步标注该决策。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-12 20:00:17 +08:00
co-authored by Claude
parent 418702295b
commit 190e59af94
3 changed files with 9 additions and 22 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+5 -3
View File
@@ -27,8 +27,9 @@
mask.h) × 0.6``scale=1` 起步——从此 `width/height` 语义 =「画布显示像素」,
渲染、碰撞、WCD 打包三者自洽;
2. `canvas-image` 保留 max 钳制作为兜底,但归一化后不再触发;
3. 拖动时把 `x/y` 钳制在 `[0, mask.w - 显示宽]` / `[0, mask.h - 显示高]` 区间内
杜绝负坐标和拖出画布。
3. ~~拖动时把 `x/y` 钳制在 `[0, mask.w - 显示宽]` / `[0, mask.h - 显示高]` 区间内~~
**已按需求撤销**,2026-09-12:贴纸允许拖出画布外自由摆放,负坐标为合法状态;
误报根因是尺寸语义而非坐标,归一化后已消除)。
**契约影响**`designData.stickers[].width/height` 的**语义**从「原始像素」变为
「画布显示像素」。这不是字段增删,但 WCD 打包按 `width × scale` 还原布局,语义必须
@@ -220,7 +221,8 @@ R4 派单前持久化回写)直接矛盾,且真机落库数据即为 wxfile:
**建议批次**:① 问题 2+3+4(同一文件、一次回归)✅ 已实施(2026-09-12commit eea6c3f
`build:weapp` 通过,tsc 无新增错误)→ ② 问题 1(含兼容验证)✅ 已实施(2026-09-12
commit 3b224cf:归一化 + 坐标钳制 + 读端兼容 + transform-origin)→
commit 3b224cf:归一化 + 坐标钳制 + 读端兼容 + transform-origin
**坐标钳制后经需求确认撤销**,commit 见后续,贴纸恢复可拖出画布)→
③ 问题 5(改动面最大,单独一批)✅ 已实施(2026-09-12commit 2e3676a
TouchSlider 组件化 + Image/CSS filter 预览 + edits 参数化保存 + DIY 渲染端
消费 editscheckout 预览消费 edits 仍记 R3 待办)。
+3 -18
View File
@@ -297,16 +297,10 @@ export default function DIYPage() {
const handleStickerTouchMove = (e: any) => {
if (!isDragging || !activeStickerId) return
const touch = e.touches[0]
// 需求决定(2026-09-12):贴纸允许拖出画布外自由摆放,不做坐标钳制
const next = stickers.map(s => {
if (s.id !== activeStickerId) return s
// 问题1 修正:坐标钳制在画布内,杜绝负坐标与拖出画布(碰撞盒 = x/y + 显示宽高)
const maxX = Math.max(0, category.mask.width - s.width * s.scale)
const maxY = Math.max(0, category.mask.height - s.height * s.scale)
return {
...s,
x: Math.min(Math.max(touch.clientX - startPos.x, 0), maxX),
y: Math.min(Math.max(touch.clientY - startPos.y, 0), maxY)
}
return { ...s, x: touch.clientX - startPos.x, y: touch.clientY - startPos.y }
})
const checked = checkOverlap(next)
setStickers(checked)
@@ -325,16 +319,7 @@ export default function DIYPage() {
const handleScale = (id: string, delta: number) => {
const next = stickers.map(s => {
if (s.id !== id) return s
const scale = Math.max(0.3, Math.min(3, s.scale + delta))
// 问题1 修正:缩放后把位置钳回画布内
const maxX = Math.max(0, category.mask.width - s.width * scale)
const maxY = Math.max(0, category.mask.height - s.height * scale)
return {
...s,
scale,
x: Math.min(Math.max(s.x, 0), maxX),
y: Math.min(Math.max(s.y, 0), maxY)
}
return { ...s, scale: Math.max(0.3, Math.min(3, s.scale + delta)) }
})
const checked = checkOverlap(next)
setStickers(checked)