\"优化 便签列表页面交互体验,添加便签滑动状态管理,防止在滑动状态下误触编辑页面\"

This commit is contained in:
yuantao
2025-10-17 14:38:57 +08:00
parent f27c3e1da6
commit 508db9e9ae
4 changed files with 46 additions and 30 deletions

View File

@@ -31,6 +31,8 @@
<script setup>
import { computed, ref } from 'vue'
const emit = defineEmits(['update:modelValue'])
const props = defineProps({
content: {
type: String,
@@ -139,6 +141,9 @@ const handlePress = () => {
// 只有在未滑动状态下才触发点击事件
if (slideOffset.value === 0 && props.onPress) {
props.onPress()
} else if (slideOffset.value !== 0) {
// 如果当前处于滑动状态,重置滑动状态(收回便签条)
resetSlideState()
}
}
@@ -169,6 +174,21 @@ const handleDelete = () => {
isSlided.value = false
}
// 重置滑动状态
const resetSlideState = () => {
slideOffset.value = 0
isSliding.value = false
isSlided.value = false
}
// 获取滑动状态
const getSlideState = () => {
return isSlided.value
}
// 暴露方法给父组件
defineExpose({ resetSlideState, getSlideState })
// 触摸开始事件处理函数
// 记录触摸开始时的X坐标用于计算滑动距离
const handleTouchStart = e => {
@@ -216,7 +236,7 @@ const handleTouchMove = e => {
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
// 只有当滑动达到一定距离时才阻止页面滚动
if (diffX > 5) {
e.preventDefault() // 防止页面滚动