fix(mobile-app): 修复火柴人超出屏幕边界问题
- 重新计算火柴人水平位置,预留终点区域和火柴人宽度 - 使用 clamp 确保火柴人不会超出右边界 - 当进度达到100%时,火柴人停在终点红旗旁边 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b04dd1f234
commit
fd9df5d065
|
|
@ -238,8 +238,13 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
|
|||
// 添加上下弹跳效果
|
||||
final bounce = _bounceController.value * 3;
|
||||
|
||||
// 计算可用宽度:容器宽度 - 左边距(20) - 右边距(终点区域80) - 火柴人宽度(60)
|
||||
final containerWidth = MediaQuery.of(context).size.width - 32; // 减去容器外边距
|
||||
final availableWidth = containerWidth - 20 - 80 - 60; // 起点边距 - 终点区域 - 火柴人宽度
|
||||
final leftPosition = 20 + availableWidth * horizontalProgress;
|
||||
|
||||
return Positioned(
|
||||
left: 20 + (MediaQuery.of(context).size.width - 120) * horizontalProgress,
|
||||
left: leftPosition.clamp(20.0, containerWidth - 80), // 确保不超出右边界
|
||||
top: verticalPosition - bounce,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
|
|
|||
Loading…
Reference in New Issue