fix: make move content

This commit is contained in:
zzc
2026-02-06 00:07:53 +08:00
parent 068391269e
commit dced5471c5

View File

@@ -51,6 +51,9 @@
<view <view
class="bubble" class="bubble"
@tap="openTool('text')" @tap="openTool('text')"
@touchstart.stop="handleBubbleTouchStart"
@touchmove.stop="handleBubbleTouchMove"
@touchend.stop="handleBubbleTouchEnd"
:style="{ :style="{
marginTop: 230 + bubbleOffsetY + 'rpx', marginTop: 230 + bubbleOffsetY + 'rpx',
maxWidth: bubbleMaxWidth + 80 + 'rpx', maxWidth: bubbleMaxWidth + 80 + 'rpx',
@@ -95,7 +98,7 @@
<view class="tip-line"> <view class="tip-line">
<view class="interaction-tip"> <view class="interaction-tip">
<uni-icons type="hand-up" size="14" color="#ff3b30"></uni-icons> <uni-icons type="hand-up" size="14" color="#ff3b30"></uni-icons>
<text>点击标题或个人信息可拖动双指可缩放标题</text> <text>点击标题祝福语或个人信息可拖动双指可缩放标题</text>
</view> </view>
</view> </view>
@@ -510,6 +513,31 @@ const handleUserTouchMove = (e) => {
} }
}; };
// 祝福语触摸交互相关
let startBubbleTouches = [];
let initialBubbleOffsetY = 0;
const handleBubbleTouchStart = (e) => {
startBubbleTouches = e.touches;
initialBubbleOffsetY = bubbleOffsetY.value;
};
const handleBubbleTouchEnd = () => {
startBubbleTouches = [];
};
const handleBubbleTouchMove = (e) => {
if (!startBubbleTouches.length) return;
if (e.touches.length === 1 && startBubbleTouches.length === 1) {
// 单指拖拽 (仅上下)
const moveY = e.touches[0].clientY - startBubbleTouches[0].clientY;
let newY = initialBubbleOffsetY + moveY * pxToRpx;
// 合理范围限制,参考 slider 的 min/max
bubbleOffsetY.value = Math.min(Math.max(newY, -200), 400);
}
};
const handleTitleTouchMove = (e) => { const handleTitleTouchMove = (e) => {
if (!currentTitle.value || !startTouches.length) return; if (!currentTitle.value || !startTouches.length) return;